Shafiul
Shafiul

Reputation: 1512

How to make nginx-docker container running always

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?

Upvotes: 1

Views: 1110

Answers (2)

Finn
Finn

Reputation: 2775

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

Upvotes: 1

Meiram Chuzhenbayev
Meiram Chuzhenbayev

Reputation: 906

You can use upstart or sustemd.

This link to official website documentation

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

Upvotes: 1

Related Questions