How to start an nginx container automatically?

Hi all,I’ve try to build and start an nginx container which start automatically when windows log on.
but it desn’t work.
here is my docker-compose.xml

version: “2”
image: nginx:1.10.1
container_name: nginx1
- 80:80
- 443:443
- 8001:8001
- 8002:8002
- /c/Users/Dev/.nginx/nginx.conf:/etc/nginx/nginx.conf:ro
- /c/Users/Dev/.nginx/html:/etc/nginx/html:ro
- /c/Users/Dev/d:/d:ro
command: /bin/sh -c “nginx -g ‘daemon off;’”
restart: always

I’ve also tried using

docker run --restart=always

the result is same.

Is there any ways to make it work?

thanks a lot.

docker run --restart=always nginx
should restart a Docker container.

1 Like

Have you considered running this with docker service create (after running docker swarm init) - that should keep it running.