基于docker的环境搭建

来源:互联网 发布:spine mac 编辑:程序博客网 时间:2024/04/28 23:46

一、简介

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

二、应用

Docker这种技术跟平常用的虚拟机很相似,但相比之下更加轻量。在工程化部署项目的时候非常好用,它实际上解决了一个开发中的痛点,开发环境和测试、生产环境的一致性。用这种方式就能够极大程度上避免这种情况,本地运行好好的,一上线服务器就挂掉了,最后发现某个包没装之类的麻烦。

三、实战

具体的操作还是找文档看吧,这里我贴上自己部署环境的Dockerfile备忘:

From xxxMAINTAINER xxx@xxx.xxxRUN yum install -y gcc python-devel openssl-devel RUN yum install -y mysql-devel RUN pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simpleRUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simpleRUN yum install -y wgetRUN wget -O /root/chrome.rpm https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpmRUN yum install -y /root/chrome.rpmRUN rm -f /root/chrome.rpmRUN wget -O /root/chromedriver.zip http://npm.taobao.org/mirrors/chromedriver/2.33/chromedriver_linux64.zipRUN yum install -y unzipRUN unzip -o /root/chromedriver.zip -d /root/RUN chmod +x /root/chromedriverRUN mv /root/chromedriver /usr/bin/chromedriverRUN rm -f /root/chromedriver.zip
上面的Dockerfile代表,以xxx镜像为基础,安装系统依赖,然后安装python包,最后是chrome浏览器和webdriver,实际上是我某个爬虫的配置。

原创粉丝点击