2

I am trying to create a service in docker with following command.

    docker service create --name nginx-proxy --network my-net --replicas=1 -p 8088:80 -p 8043:443 --mount type=bind,src=/opt/my/nginx,dst=/etc/nginx/conf.d,readonly=true --constraint 'node.labels.nginx == yes' nginx 

I am getting following error:

7p5u1p5d25rd7poy3qd3szzp0   \_ docu-proxy.1  nginx  docker-swarm-0  Shutdown       Failed 6 seconds ago    "task: non-zero exit (1)"

I suspect it is because of --mount option I am using into the command. Is anything wrong with this command.

Munish Dhiman
  • 511
  • 1
  • 7
  • 22
  • What is the output of `docker logs $(docker inspect --format "{{.Status.ContainerStatus.ContainerID}}" ID_HERE)` (`ID_HERE` is the id of the failed service: can be found with `docker service ps nginx-proxy`) – Salem Feb 17 '17 at 21:09
  • I Updated the docker version with latest one and luckily I was able to read the proper error message using containers logs. It was because of the service discovery failure I removed that service from the configuration file and started working. Thanks :P – Munish Dhiman Feb 20 '17 at 12:17
  • If you managed to solve your problem consider posting an answer with the steps and mark it as solved. Those steps may help someone with a similar problem – Salem Feb 21 '17 at 10:38

1 Answers1

1

To run Nginx docker container as a service in swarm mode one should ensure that all the services, used into the nginx as a upstream server, are running otherwise service discovery would get fail and your nginx service would also get failed.

Munish Dhiman
  • 511
  • 1
  • 7
  • 22