Olá.
Já desenvolvi aplicação usando docker-compose
. Estou tentando desenvolver algo utilizando Nginx
que próprio curso de Docker
apresenta.
Entretanto quando executo docker-compose up
ele apresenta o erro
Starting nginx ...
Starting nginx ... done
Attaching to nginx
nginx | 2018/03/13 02:17:02 [emerg] 1#1: "server" directive is not allowed here in /etc/nginx/nginx.conf:2
nginx | nginx: [emerg] "server" directive is not allowed here in /etc/nginx/nginx.conf:2
nginx exited with code 1
Meu docker-compose.yaml
meu yaml está 80% comentado para apenas testar levantar o servidor
version: '3'
services:
# mysql:
nginx:
build:
dockerfile: ./docker/nginx.dockerfile
context: .
image: nginx:latest
container_name: nginx
ports:
- "80:80"
networks:
hospital-network:
ipv4_address: 172.19.0.6
volumes:
- ./docker/config/:/etc/nginx/
- ./client:/var/www
# depends_on:
# - node1
# - node2
# - node3
# node1:
# build:
# dockerfile: ./dockerfile/hospital-api.dockerfile
# context: .
# image: node:latest
# container_name: node1
# ports:
# - "3000"
# networks:
# hospital-network:
# ipv4_address: 172.19.0.7
# volumes:
# - .:/var/www
# working_dir: /var/www
# command: bash -c "npm i -g nodemon && npm i"
# node2:
# build:
# dockerfile: ./dockerfile/hospital-api.dockerfile
# context: .
# image: node:latest
# container_name: node2
# ports:
# - "3000"
# networks:
# hospital-network:
# ipv4_address: 172.19.0.8
# volumes:
# - .:/var/www
# working_dir: /var/www
# command: bash -c "npm i -g nodemon && npm i"
# node3:
# build:
# dockerfile: ./dockerfile/hospital-api.dockerfile
# context: .
# image: node:latest
# container_name: node3
# ports:
# - "3000"
# networks:
# hospital-network:
# ipv4_address: 172.19.0.9
# volumes:
# - .:/var/www
# working_dir: /var/www
# command: bash -c "npm i -g nodemon && npm i"
# node:
# image: node:latest
# container_name: node
# networks:
# hospital-network:
# ipv4_address: 172.19.0.5
# ports:
# - 3000:3000
# # depends_on:
# # - "mysql"
# volumes:
# - ./server:/api
# working_dir: /api
# command: bash -c "npm i -g nodemon && npm i && npm start"
networks:
hospital-network:
driver: bridge
ipam:
config:
- subnet: 172.19.0.0/16
E esse é o docker-file
FROM nginx:latest
LABEL Author="Gustavo Soares"
COPY /client/public /var/www/public
COPY /docker/config/nginx.conf /etc/nginx/nginx.conf
RUN chmod 755 -R /var/www/public
EXPOSE 80
ENTRYPOINT [ "nginx" ]
CMD [ "-g", "daemon off;" ]
Caso tenham alguma outra dúvida,
esse é meu git https://github.com/GustavoFSoares/hospital/
. O projeto é público e qualquer um pode acessar.
De todo modo, obrigado pela força!