Sobes.tech
Junior — Middle

Does the container automatically start when the server's operating system restarts?

sobes.tech AI

Answer from AI

By default, Docker containers do not start automatically after the operating system is rebooted. To make a container start automatically, you need to explicitly specify a restart policy when creating or configuring the container.

For example, when running a container, you can use the --restart option:

docker run --restart unless-stopped my-container

Possible values for --restart:

  • no — do not restart the container automatically (default value)
  • on-failure — restart the container on failure
  • always — always restart the container
  • unless-stopped — restart unless the container was manually stopped

Thus, to have the container start automatically upon server restart, you need to set the appropriate restart policy.