当我运行docker-compose up all work good。重启后我的静态文件出现问题。所有容器都启动,但在静态文件请求时我们得到404。
又一次,服务器重启后问题就开始了。当我说:
docker-compose up
一切都很完美。
搬运工-compose.yml
web:
restart: always
build: .
command: /usr/local/bin/gunicorn ems3.wsgi:application -w 2 -b :8031
volumes:
- .:/code
ports:
- "8031:8031"
links:
- db
nginx:
restart: always
build: ./nginx/
ports:
- "8002:8002" # 443
- "8001:8001" # 80
volumes:
- /www/static
volumes_from:
- web
links:
- web:web
db:
restart: always
image: postgres
ports:
- "5555:5555"
environment:
- POSTGRES_PASSWORD=mysecr3333
- POSTGRES_USER=postgres
web:
restart: always
build: .
command: /usr/local/bin/gunicorn ems3.wsgi:application -w 2 -b :8031
volumes:
- .:/code
ports:
- "8031:8031"
links:
- db
nginx:
restart: always
build: ./nginx/
ports:
- "8002:8002" # 443
- "8001:8001" # 80
volumes:
- /www/static
volumes_from:
- web
links:
- web:web
db:
restart: always
image: postgres
ports:
- "5555:5555"
environment:
- POSTGRES_PASSWORD=mysecr3333
- POSTGRES_USER=postgres
nginx_config
server {
listen 8002 ssl default;
location /static {
alias /code/static;
}
location / {
proxy_pass http://web:8031;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header Host $host:$server_port;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
答案 0 :(得分:0)
我的问题是通过使用docker-compose版本2文件格式决定的。似乎有点不同,但它正在发挥作用。 docker-compose.yaml看起来像这样:
version: '2'
services:
web:
restart: always
build: .
command: /usr/local/bin/gunicorn proj.wsgi:application -w 2 -b :8031
volumes:
- web_code:/code
ports:
- "8031:8031"
links:
- db
volumes:
web_code:
driver: local
添加了版本2 ,添加了命名卷,并使用driver:local添加了卷。 几根琴弦,但是很痛苦。