1

I am trying to run a docker container for nginx providing reverse-proxy.

The command I am trying is:

docker run --name nginx-proxy -p 80:80 -v ./nginx.conf:/etc/nginx/nginx.conf:ro -v ./logs/nginx:/var/log/nginx -d nginx

but it stops immediately after started. Result of docker ps -a is:

CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                         PORTS                  NAMES
89b3526e2c25        nginx                       "nginx -g 'daemon off"   11 seconds ago      Exited (1) 10 seconds ago                             nginx-proxy

How can I make this container always running?

2
  • 2
    please provide logs docker logs 89b3526e2c25 Commented May 4, 2016 at 11:31
  • You pointed me to right direction. There were several issues(e.g. nginx: [emerg] no "events" section in configuration) in my nginx.conf file. docker logs provided hints on those errors. Now its running fine. Thanks. Commented May 4, 2016 at 11:53

2 Answers 2

1

You can use upstart or sustemd.

This link to official website documentation

https://docs.docker.com/engine/admin/host_integration/

Sign up to request clarification or add additional context in comments.

Comments

1

I saw incorrect syntax here "nginx -g 'daemon off". You can try to edit the command or rebuild Dockerfile with ENTRYPOINT like ["nginx", "-g", "daemon off"]

Another way, add the line below to nginx.conf before build Dockerfile.

RUN echo "daemon off;" >> /etc/nginx/nginx.conf

1 Comment

It's the default nginx image, I didn't change anything. now its running fine after fixing nginx.conf.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.