實戰(zhàn):使用Docker配置ubuntu下的scrapy爬蟲環(huán)境

最開始發(fā)布于http://blog.csdn.net/windcao/article/details/50575145

1 準(zhǔn)備docker容器

1.1 安裝DockerToolBox

參考:
http://www.oschina.net/translate/installing-docker-on-mac-os-x
https://github.com/boot2docker/osx-installer/releases

1.2 配置ubuntu鏡像

<pre>
$docker pull daocloud.io/ubuntu:14.04
</pre>

1.3 啟動docker鏡像進(jìn)入ubuntu14.04

<pre>
$docker run -it ubuntu:14.04
</pre>

2 docker容器中的安裝

2.1 更新apt-get

<pre>

apt-get update

</pre>

2.2 安裝python2.7.6

<pre>

sudo apt-get install python

</pre>

2.3 安裝wget,命令行下面下載文件的工具

<pre>

apt-get install wget

</pre>

2.4 進(jìn)入臨時目錄以下載安裝所需文件

<pre>

cd tmp

</pre>

2.5 下載并安裝pip

<pre>

wget https://bootstrap.pypa.io/get-pip.py

python get-pip.py

</pre>

---------------- base end -----------------

2.6 安裝make

<pre>

apt-get install make

</pre>

2.7 安裝g++

<pre>

apt-get install build-depgcc

apt-get install build-essential

</pre>

--------- gcc end ------------

2.8 安裝依賴

<pre>

apt-get install libxml2-dev libxslt1-dev

apt-get install libgsl0-dev

apt-get install python-dev

apt-get install libffi-dev

apt-get install libssl-dev

</pre>

--------- dep end ------------

2.9安裝scrapy

<pre>

pip install scrapy

</pre>

3 如何保存修改

3.1 退出dockerTerminal

<pre>

exit

</pre>

3.2 查看containerId

<pre>
$docker ps -a -q
cc4072aadb13
</pre>

3.3 保存鏡像

<pre>
$ docker commit cc40 ubuntu/spider
02db509cb269710f8f80b2a35f12995c59c668b3e3ba2e7148987bc55d713fa5
</pre>

3.4 查看剛才保存的鏡像

<pre>
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
ubuntu/spider latest 138b6860da02 About a minute ago 228.2 MB
ubuntu latest 6cc0fc2a5ee3 3 days ago 187.9 MB
ubuntu 14.04 6cc0fc2a5ee3 3 days ago 187.9 MB
honeydeiMac:~ caojianfeng$
</pre>

3.5你可以使用如下命令進(jìn)入之前安裝的環(huán)境了

<pre>
$docker run -it ubuntu/spider
</pre>

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容