利用 docker 配置 pinbot-crawl 环境

pinbot-crawl 是我在开发的一个爬虫项目,它应用到的东西相对较多,oursql, python3-memcached, gearman, python3。

docker 挺好玩的我就用了一下配置了运行环境,如下

$ # start a container

$ docker run -i -t ubuntu:12.04 /bin/bash
# # update the source
# apt-get update
# # install python3 and python3-dev
# apt-get install python3 python3-dev
# # install the setuptools
# apt-get install python3-setuptools
# # oh fuck forget to mount the source dirctory
# exit
$ # use docker ps -a to find the above container_id
$ docker ps -a
$ # my container_id is 4823a1bfd668 commit it
$ docker commit 4823a1bfd668 lmj/pinbot-crawl
$ # mount the soure dirctory and enter the continer
$ docker run -v /home/lmj/project/mygithub/crawl:/root/crawl -i -t lmj/pinbot-crawl /bin/bash
# # install the packages crawl
# cd /root/crawl
# python3 setup.py build
# python3 setup.py install
# # the dependencies requests is install error


# create a new terminal then download the requests packages into /home/lmj/project/mygithub/crawl
$ cd /home/lmj/project/mygithub/crawl
$ wget https://github.com/kennethreitz/requests/archive/master.zip
$ unzip master.zip 
$ now change to the container


# # install the requests
# cd requests-master
# python3 setup.py install
# cd ..


# # reinstall crawl
# python3 setup.py install
# # that is install success


# # now exit the container and commit it
# exit 
$ docker ps -a 
$ docker commit  f417f9219cd3 lmj/pinbot-crawl


$ # now we are install the base packages crawl


$ # install the mysql support
$ # prepare
$ cd /tmp
$ wget https://launchpad.net/oursql/py3k/py3k-0.9.3/+download/oursql-0.9.3.zip
$ unzip oursql-0.9.3.zip
$ # mount the /tmp for container
$ docker run -v /tmp:tmp -i -t lmj/pinbot-crawl /bin/bash
# apt-get install libmysqlclient-dev
# cd /tmp 
# cd oursql-0.9.3
# python3 setup.py build
# python3 setup.py install
# exit
$ docker ps -a
$ docker commit 73e82505f0b4 lmj/pinbot-crawl


$ # install python3-memcached
$ docker run -i -t lmj/pinbot-crawl /bin/bash
# easy_install3 python3-memcached
# exit
$ docker ps -a
$ docker commit d3b0f503a8fe lmj/pinbot-crawl


$ # gearman client
$ cd /tmp
$ wget http://cython.org/release/Cython-0.19.1.tar.gz
$ tar xvf  Cython-0.19.1.tar.gz
$ wget https://github.com/Lupino/py3k-gearman/archive/master.zip
$ unzip master.zip
$ docker run -v /tmp:tmp -i -t lmj/pinbot-crawl /bin/bash
# cd /tmp
# cd Cython-0.91.1
# python3 setup.py build
# python3 setup.py install
# cd ../py3k-gearman-master
# python3 setup.py build
# python3 setup.py install
# apt-get clean
# exit
$ docker ps -a
$ docker commit c25330ffe62c lmj/pinbot-crawl

你可能感兴趣的:(利用 docker 配置 pinbot-crawl 环境)