赞
踩
以centos7.6为基础镜像,构建带有python3.6.8的镜像
FROM centos:7.6.1810 ENV PATH $PATH:/usr/local/python3/bin/ ENV PYTHONIOENCODING utf-8 RUN set -ex \ && mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup \ && curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo \ && yum makecache \ && sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo \ && yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget \ && yum clean all \ && mkdir /usr/local/python3 \ && wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz \ && tar -xvJf Python-3.6.8.tar.xz && rm -f Python-3.6.8.tar.xz \ && cd Python-3.6.8 \ && ./configure prefix=/usr/local/python3 \ && make && make install \ && cd .. \ && rm -rf Python-3.6.8 CMD ["usr","bin","bash"]
FROM centos:7.6.1810 WORKDIR /server COPY . /server ENV SCRAPYD_PORT 6800 RUN set -ex \ && yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget \ && yum clean all \ && mkdir /usr/local/python3 \ && wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz \ && tar -xvJf Python-3.6.8.tar.xz && rm -f Python-3.6.8.tar.xz \ && cd Python-3.6.8 \ && ./configure prefix=/usr/local/python3 \ && make && make install \ && ln -s /usr/local/python3/bin/python3.6 /usr/local/bin/python3 \ && ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3 \ && cd .. \ && rm -rf Python-3.6.8 \ && pip3 install -r requirements.txt \ && ln -s /usr/local/python3/bin/scrapyd /usr/local/bin/scrapyd \ && sed -i 's#127.0.0.1#0.0.0.0#g' /usr/local/python3/lib/python3.6/site-packages/scrapyd/default_scrapyd.conf CMD ['scrapyd']
启动方式
docker run -d -p 6800:6800 image_id scrapyd
访问本机内网地址6800端口即可。
FROM centos:7.6.1810 WORKDIR /server COPY . /server ENV SCRAPYD_PORT 6800 RUN set -ex \ && yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make wget \ && yum clean all \ && mkdir /usr/local/python3 \ && wget https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz \ && tar -xvJf Python-3.6.8.tar.xz && rm -f Python-3.6.8.tar.xz \ && cd Python-3.6.8 \ && ./configure prefix=/usr/local/python3 \ && make && make install \ && ln -s /usr/local/python3/bin/python3.6 /usr/local/bin/python3 \ && ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3 \ && cd .. \ && rm -rf Python-3.6.8 \ && pip3 install -r requirements.txt \ && ln -s /usr/local/python3/bin/scrapyd /usr/local/bin/scrapyd \ && sed -i 's#127.0.0.1#0.0.0.0#g' /usr/local/python3/lib/python3.6/site-packages/scrapyd/default_scrapyd.conf \ && echo '#!/bin/bash' >>runserver.sh \ && echo 'sed -i "s#6800#$SCRAPYD_PORT#g" /usr/local/python3/lib/python3.6/site-packages/scrapyd/default_scrapyd.conf' >>runserver.sh \ && echo 'scrapyd' >> runserver.sh CMD ["bin","bash"]
启动方式,不指定SCRAPYD_PORT则默认为6800
docker run -d -e SCRAPYD_PORT=6999 -p 6999:6999 image_id /bin/bash runserver.sh
#设置工作目录
WORKDIR /app
#Copy the current directory contents into the container at /app
COPY . /app
#Make port 80 available to the world outside this container
EXPOSE 80
#Define environment variable
ENV NAME World
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。