Reputation: 3051
I am trying to setup Docker for my django project. I believe everything is setup to run docker in my machine. Currently, the docker version
gives following output:
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
I have setup my docker-compose.yml
file as follows:
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
successfully builds docker images and shows following message:
Successfully built 6b13b02488dc
Successfully tagged loopserver_web:latest
nginx uses an image, skipping
But, when I try to run docker-compose up
following error occurs:
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.
And theserver.conf
file inside config/nginx
folder.
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;
}
I am using docker
for the first time and stuck with this error. Any guidance will be very helpful.
Upvotes: 1
Views: 533
Reputation: 36733
I leave the answer here to consult in the future.
As we investigated, it seems that there is some issue in your docker-compose version (< 1.12.0) with python3.
Bug: https://github.com/docker/compose/issues/4729
They recommend to upgrade to Python 3.4.4+ or 3.5.1+, and it should be fixed.
Upvotes: 1
Reputation: 1609
in web
service, just add:
environment:
- NGINX_HOST=foobar.com
- NGINX_PORT=80
for more information: docker nginx
Upvotes: 0