How to Automatically Start Your Docker Containers

installing docker on vps

People talk about docker being useful for testing environment and stuff. But docker is also used for running your development environment applications like Nexus. Which is what we are doing in our dev environment. We have a Nexus instance running as a Docker container. The thing is you will probably run your docker on a Linux distro and you need to make sure that in case your Linux gets restarted for some reason your Docker service and your containers get started automatically.

To do this there are 2 things you need to configure.

1- Make sure the Docker service starts automatically when your OS restarts.

2- Make sure your containers start automatically when the Docker service is up.

To achieve 1, there is a  Linux command line command you need to run:

To achieve 2, you need to update your existing docker containers using this command:

Now you can restart your Linux server and see these changes in effect.

Hope this helps.
Good Luck,
Serdar