基于docker的环境搭建

一、简介

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

二、应用

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

三、实战

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

From xxx

MAINTAINER xxx@xxx.xxx

RUN 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/simple
RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

RUN yum install -y wget
RUN wget -O /root/chrome.rpm https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
RUN yum install -y /root/chrome.rpm
RUN rm -f /root/chrome.rpm

RUN wget -O /root/chromedriver.zip http://npm.taobao.org/mirrors/chromedriver/2.33/chromedriver_linux64.zip
RUN yum install -y unzip
RUN unzip -o /root/chromedriver.zip -d /root/
RUN chmod +x /root/chromedriver
RUN mv /root/chromedriver /usr/bin/chromedriver
RUN rm -f /root/chromedriver.zip
上面的Dockerfile代表,以xxx镜像为基础,安装系统依赖,然后安装python包,最后是chrome浏览器和webdriver,实际上是我某个爬虫的配置。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值