У меня есть два файла docker-compose.yml, один для настройки контейнера, а другой для любого последующего запуска контейнера:
docker-compose.setup.yml:
version: '3'
services:
db:
image: "postgres:11.1"
env_file:
- ./volumes/postgres_config/env_file
networks:
- db_nw
pyramid_app:
image: image_from_dockerfile
env_file:
- ./volumes/postgres_config/env_file
volumes:
- ./volumes/pyramid_app:/app/src
image: image_from_dockerfile
working_dir: /app
expose:
- 6543
command: >
sh -c "/app/venv/bin/pip install -r /app/src/requirements.pip &&
/app/venv/bin/pip install -e '/app/src[testing]' &&
/app/venv/bin/pserve /app/src/development.ini --reload"
networks:
- db_nw
- web_nw
depends_on:
- db
nginx:
image: nginx:1.13.5
ports:
- "6543:80"
volumes:
- ./volumes/nginx_config:/etc/nginx/conf.d
networks:
- web_nw
depends_on:
- pyramid_app
networks:
db_nw:
driver: bridge
web_nw:
driver: bridge
volumes:
conf.d:
src:
docker-compose.yml:
version: '3'
services:
db:
image: "postgres:11.1"
env_file:
- ./volumes/postgres_config/env_file
networks:
- db_nw
pyramid_app:
image: image_from_dockerfile
env_file:
- ./volumes/postgres_config/env_file
volumes:
- ./volumes/pyramid_app:/app/src
image: image_from_dockerfile
working_dir: /app
expose:
- 6543
command: /app/venv/bin/pserve /app/src/development.ini --reload
networks:
- db_nw
- web_nw
depends_on:
- db
nginx:
image: nginx:1.13.5
ports:
- "6543:80"
volumes:
- ./volumes/nginx_config:/etc/nginx/conf.d
networks:
- web_nw
depends_on:
- pyramid_app
networks:
db_nw:
driver: bridge
web_nw:
driver: bridge
volumes:
conf.d:
src:
Docker-compose.setup.yml работает нормально и запускает мое веб-приложение, но я получаюОшибка «нет такого файла или каталога» в любое время, когда я пытаюсь запустить следующий файл docker-compose.yml:
PS C:\Users\Raj\Projects\github_example> docker-compose up
Starting 81f076500a73_github_example_db_1 ... done
Recreating bc2fafc2039d_github_example_pyramid_app_1 ... error
ERROR: for bc2fafc2039d_github_example_pyramid_app_1 Cannot start service pyramid_app: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"/app/venv/bin/pserve\": stat /app/venv/bin/pserve: no such file or directory": unknown
ERROR: for pyramid_app Cannot start service pyramid_app: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"/app/venv/bin/pserve\": stat /app/venv/bin/pserve: no such file or directory": unknown
ERROR: Encountered errors while bringing up the project.
Кроме того, это мой Dockerfile:
FROM ubuntu:18.04
MAINTAINER Raj <raj@fake.email>
ENV PYTHONUNBUFFERED 1
RUN apt-get -yqq update && apt-get install -yqq python3 python3-dev python3-pip python3-venv
RUN mkdir -p /app/venv
RUN python3 -m venv /app/venv
RUN ls /app/venv
RUN /app/venv/bin/pip install --upgrade pip setuptools
WORKDIR /app