Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL EXTENSION

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL EXTENSION

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

Docker restart container on reboot – Here is how we do it

by | Dec 1, 2019

Want Docker to restart container on reboot?

This is quite simple with the Docker restart policies or a Process Manager.

But the better choice is to use the restart policy. Because it specifies how a container restart on exit.

At Bobcares, we often get requests to restart Docker on reboot, as a part of our Docker Hosting Support.

Today, we will see how our Support Engineers enable restart policy for Docker.

 

Snapshot on Docker restart policy

The restart policy is part of the container metadata. When we create the container, the metadata gets created.

By using the --restart flag we can specify the restart policy for a Docker. The default restart policies are

  • no – This default policy means no automatic restart of the container.
  • on-failure – It restarts the container only if it exits with a non-zero exit status.
  • always – It always restarts the container without looking for the current status of the container.
  • unless-stopped – Restart the container always except stopped.

Now let us see how to restart the container on reboot.

 

How we configure docker containers to restart on reboot?

Our Experts often configure Docker containers to restart on reboot. And we always recommend using a restart policy. Alternatively, we can also use a Process Manager for the same purpose.

 

Restart policy to restart Docker on reboot

By default, the restart policy in Docker is no. For already created containers, our Support Engineers use docker update to start restart policy.

The command appears as,

Docker restart container on reboot.

Here 0576df221c0b is the container ID.

Similarly, for the newly created container, we use the command,

Docker restart container on reboot in new container.

This will make Docker restart on reboot.

 

Using Process manager to restart Docker on reboot

In some cases, we use a Process Manager in Linux to automatically restart services that fail. Common Process Managers are systemd, supervisor, etc.

We can use this in the case of Docker also.  We recommend this option only if any outside process depends on the docker container.

Now, we will see how our Support Engineers use a Process Manager to restart Docker.

For this, we configure the Process Manager to start the container using the default manual commands.

But we do not recommend to use both the restart policy along with the Process Manager. Similarly, it is not advisable to use the Process Manager inside a container.

[Need assistance in managing Docker? – We will help you.]

 

Conclusion

So far, we saw two ways for a Docker to restart the container on reboot. The recommended method is to use Docker restart policy. But we may also use the Process Manager in some cases. Today, we also saw how our Support Engineers do this for our customers.

Are you using Docker based apps?

There are proven ways to get even more out of your Docker containers! Let us help you.

Spend your time in growing business and we will take care of Docker Infrastructure for you.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.