简体   繁体   中英

Docker containers onlys up when access the host with ssh

I have two containers it was builded with command > docker-compose up --build -d. All containers build normally and stays up, but when I leave the machine the containers stays up at least 2 hours until que he drops again.

This containers is running an API in PHP LARAVEL Framework and a nginx reverse proxy.

Docker Image Started as 46Hours ago and UP 2 seconds

When I start the application and leave the machine where Docker is installed, it is in max two hours running. If I access the machine via ssh and then after that access the application and it is running without the need to do a docker-compose up. And the api was written in Laravel PHP with a Nginx container making a reverse Proxy.

What do I have to do to make these containers stand up as a productive environment?

There is a command that can help you when it goes down or stops:

sudo docker run --restart unless-stopped --name <Name you want to use> <Name of your container>

don't use these <> in your command

after doing this anytime that container is down it will restart the container for you automatically.

I think this trick is really useful when you have multiple containers running, and helpful when you want to update the server packages too.

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