初学者的Docker docker-compose

我正在阅读本教程,并已成功启动并运行了该堆栈。

什么是我的问题是,当我在我的主机上更改我的代码(在web服务中)时,它在浏览器中重新加载页面时自动进行更改。 我不明白为什么这样做。 这是我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 

我不认为这是重新加载gunicorn ,因为我相信gunicorn需要 – 重新加载标志实际上热重新加载。

这一行意味着您将主机上的位置映射到Web容器中的位置。

  volumes: - ./web:/usr/src/app - ./web/static:/usr/src/app/static 

因此,无论何时您更改您在.web目录中更改代码,它都将在容器中更新。 如果您不希望发生这种情况,则需要在通过在该容器的Dockerfile中指定容器来构build容器时复制这些目录。