我正在使用码头工具创建,其中一个图像使用dockerfile构建,其他图像是标准图像。由dockerfile('网站')控制的图像具有 COPY。/gp_flask (该目录是早先创建的)。 它工作正常时码头工人使用码头机部署时不起作用
docker-compose up --build
发生在我的Ubuntu机器上。它复制一个目录结构。
然而,当我使用EC2泊坞窗机,有目录中没有的内容(在泊坞窗) 我的COPY后立即加入
RUN ls -la /gp_flask
,并正确显示的所有内容。 接下来的唯一命令是EXPOSE
端口和CMD ["/usr/bin/supervisord"]
COPY复制supervisord和nginx配置文件的命令可以正常工作。
尚未构建过程完成后,其他容器的一个失败,因为它无法找到/ gp_flask的东西,果然如我 泊坞窗,构成EXEC网站/斌/庆典 目录/ gp_flask 现在是空的。
这只发生在我在码头机环境中运行时。 docker-compose在我的本地机器上工作正常。
另外,如果我使用泊坞窗机,并与eval "$(docker-machine env gpflask)"
启动两发炮弹,然后在一个我做的:
docker build -t gp_flask .
,并在其他:
docker exec -it mad_fermat /bin/bash
然后我可以看到COPY (在EC2泊坞窗引擎实例上)。
所以这意味着docker-compose在远程docker引擎上有所不同。 COPY
之后的RUN ls
的成功似乎表明该副本正在工作,但在构建过程中稍后的映像将其删除,但基本上没有以下命令。
FROM python:3.5
MAINTAINER Tim Richardson <[email protected]>
RUN apt-get update && apt-get install -qq -y \
build-essential libpq-dev --no-install-recommends
RUN apt-get install -qq -y vim --no-install-recommends
RUN apt-get install -qq -y nginx --no-install-recommends
RUN apt-get install -qq -y supervisor --no-install-recommends
RUN apt-get install -qq -y python3-dev python3-pip python3-setuptools --no-insta
ll-recommends
# RUN apt-get install -qq -y openssh-server --no-install-recommends
#RUN mkdir -p /var/run/sshd
COPY requirements.txt requirements.txt
COPY requirements requirements
RUN pip3 install -r requirements.txt
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ENV INSTALL_PATH /gp_flask
RUN mkdir -p $INSTALL_PATH
COPY nginx.conf /etc/nginx/nginx.conf
RUN rm /etc/nginx/sites-enabled/default
WORKDIR $INSTALL_PATH
COPY . /gp_flask
RUN ls -la /gp_flask
EXPOSE 8000
EXPOSE 5000
EXPOSE 5001
#note that if you change the name of the app, you have to change the command lin
e to gunicorn
#gunicorn is started in supervisord setup
#CMD gunicorn -b 0.0.0.0:8001 --access-logfile - "dear_flask.app:create_app()"
CMD ["/usr/bin/supervisord"]
,这里是泊坞窗,compose.yml
version: '2'
services:
postgres:
image: 'postgres:9.5'
env_file:
- '.env'
volumes:
- 'postgres:/var/lib/postgresql/data'
ports:
- '5432:5432'
redis:
image: 'redis:3.0-alpine'
command: redis-server --requirepass devpassword
volumes:
- 'redis:/var/lib/redis/data'
ports:
- '6379:6379'
website:
build: .
command: >
/usr/bin/supervisord
env_file:
- '.env'
volumes:
- '.:/gp_flask'
ports:
- '8000:8000'
- '5000:5000'
- '5001:5001'
celery:
build: .
command: celery worker -l debug -A dear_flask.dear.tasks
env_file:
- '.env'
volumes:
- '.:/gp_flask'
volumes:
postgres:
redis:
,这里是supervisord.conf
[supervisord]
logfile_maxbytes=50MB
logfile_backups=10
logfile=/tmp/supervisord.log
loglevel=info
pidfile=/tmp/supervisord.pid
nodaemon=true
minfds=1024
minprocs=200
directory=/gp_flask/
[supervisorctl]
#[program:sshd]
#command=/usr/sbin/sshd -D
[program:nginx]
command=/usr/sbin/nginx -g "daemon off;"
#command=ls # a dummy command convenient for disabling nginx
[program:gunicorn]
command=/usr/local/bin/gunicorn -b 127.0.0.1:8001 "dear_flask.app:create_app()"
directory=/gp_flask/
您是否能够验证您刚刚构建的相同图像正在运行?您是否会列出远程构建,标记,推送和运行映像的步骤,以及运行时查看该文件夹在运行时是否为空的命令?用compose,你会显示那个yml的内容,也许一个卷挂载在/ gp_flask。 – BMitch
当我执行然后简单地执行 ,然后在另一个终端重复eval,然后在容器上启动一个shell COPY显然有效。因此,即使在远程EC2实例上,Dockerfile也不错。我会将.yml添加到问题中,但是当我在我的linux机器上本地运行它时,docker-compose会发挥作用。当docker-machine参与时,我只遇到了这个问题。 –
至于我在做docker-compose的时候看到/ gp_flask是空的,我只是简单地执行docker-compose exec website/bin/bash –