[英]Beginner Docker docker-compose
I'm going through this tutorial and I've successfully got the stack up and running. 我正在阅读本教程,并且已经成功启动并运行了堆栈。
What's bugging me is that when I change my code (in the web
service) on my host, it does automatically make the changes when I reload the page in the browser. 让我感到烦恼的是,当我在主机上更改代码(在web
服务中)时,当我在浏览器中重新加载页面时,它会自动进行更改。 I don't understand why it's doing that. 我不明白为什么要这么做。 Here's my docker-compose.yml
file: 这是我docker-compose.yml
文件:
web:
restart: always
build: ./web
expose:
- "8000"
links:
- postgres:postgres
- redis:redis
volumes:
- ./web:/usr/src/app
- ./web/static:/usr/src/app/static
env_file: .env
environment:
DEBUG: 'true'
command: /usr/local/bin/gunicorn docker_django.wsgi:application -w 2 -b :8000
nginx:
restart: always
build: ./nginx/
ports:
- "80:80"
volumes:
- /www/static
volumes_from:
- web
links:
- web:web
postgres:
restart: always
image: postgres:latest
ports:
- "5432:5432"
volumes:
- pgdata:/var/lib/postgresql/data/
redis:
restart: always
image: redis:latest
ports:
- "6379:6379"
volumes:
- redisdata:/data
I didn't think that this was gunicorn
doing the reloading because I believe gunicorn
needs the --reload
flag to actually do hot reloading. 我不认为这是gunicorn
做重装,因为我相信gunicorn
需要--reload
标志实际上做热重装。
This line means that you are mapping locations on your host to locations within your web container. 此行表示您正在将主机上的位置映射到Web容器内的位置。
volumes:
- ./web:/usr/src/app
- ./web/static:/usr/src/app/static
Therefore any time you change you change code in the .web directory, it is updated within the container. 因此,每次更改.web目录中的代码时,该代码都会在容器中更新。 If you don't want that to happen then you need to copy those directories when you build your container by specifying that in Dockerfile for that container. 如果您不希望发生这种情况,那么在构建容器时,需要在Dockerfile中为该容器指定复制这些目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.