【发布时间】:2017-11-05 02:56:26
【问题描述】:
我正在尝试为我的 django 项目设置 Docker。我相信一切都已设置好在我的机器上运行 docker。目前,docker version 提供以下输出:
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.2.1
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 17.05.0-ce
Server API version: 1.29
Go version (server): go1.7.5
Git commit (server): 89658be
OS/Arch (server): linux/amd64
我已将我的docker-compose.yml 文件设置如下:
version: '3'
services:
nginx:
restart: always
image: nginx:latest
container_name: NGINX
ports:
- "8000:8000"
volumes:
- ./src:/src
- ./config/nginx:/etc/nginx/conf.d
- /static:/static
depends_on:
- web
web:
restart: always
build: .
container_name: DJANGO
command: bash -c "python manage.py makemigrations && python manage.py migrate && gunicorn loop.wsgi -b 0.0.0.0:8000 --reload"
depends_on:
- db
volumes:
- ./src:/src
- /static:/static
expose:
- "8000"
db:
restart: always
image: postgres:latest
container_name: PSQL
docker-compose build 成功构建 docker 镜像并显示以下消息:
Successfully built 6b13b02488dc
Successfully tagged loopserver_web:latest
nginx uses an image, skipping
但是,当我尝试运行docker-compose up 时出现以下错误:
Creating NGINX ...
Creating NGINX ... error
ERROR: for NGINX Cannot create container for service nginx: invalid port specification: "None"
ERROR: for nginx Cannot create container for service nginx: invalid port specification: "None"
ERROR: Encountered errors while bringing up the project.
还有config/nginx文件夹中的server.conf文件。
upstream web {
ip_hash;
server web:8000;
}
# portal
server {
location /static/ {
autoindex on;
alias /static/;
}
location / {
proxy_pass http://web/;
}
listen 8000;
server_name localhost;
}
我第一次使用docker 并遇到此错误。任何指导都会非常有帮助。
【问题讨论】:
-
./config/nginx里有什么? -
我在
config/nginx文件夹中有server.conf文件。 -
问题可能就在那里。可以给我看看吗?
-
他们说:升级到 Python 3.4.4+ 或 3.5.1+ 应该可以解决问题。
-
谢谢@罗伯特。它适用于 python 3.5.1+
标签: django nginx docker docker-compose docker-machine