简体   繁体   中英

How to run docker container in production in Centos?

So on my server, I run my docker container as a daemon process via:

docker run -p 80:80 -td example

It seems to work fine - for now!

But, what if I restart my server or my docker container crashes? Then it doesn't work fine.

What is the best/conventional/standard way to keep my docker container running?

Thanks!

What you are looking for is an orchestrator. An orchestrator will manage your container life cycle for you. You might want to try the Docker orchestrator, Swarm. You can also check Kubernetes or Mesos.

You could also use Docker compose to make things easier.

As @wassim-dif pointed out you might want to use an orchestrator.

If you just want your docker container to restart automatically in case of failure and when you restart your server then you need to run it using the --restart flag, such as:

docker run -p 80:80 -td --restart=always example

This way, your container will restart automatically.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM