How to configure Photon OS to auto start containers at boot time

In this guide I will show you how to configure Photon OS to start a container when the OS boots up. This way your container is running even if the OS gets powered off or rebooted. Or if you are running on vSphere and an HA event occurs.

Pre-Reqs

  • At lease one Photon OS VM running, download from here
  • At least one container installed and running, I am using Admiral in my example, see my guide here
  • A quiet place where you will not be interrupted see my guide here

SSH into your Photon OS where your container is running and create a service file for the container that you want to auto start at boot time

Use vi editor to create a service file in /etc/systemd/system I named mine docker-admiral.service

/etc/systemd/system/docker-admiral.service

Click i and enter the information for the docker container you want to start

If this is not for admiral see items in red below that you will need to change for the container you want to start.

When everything is entered correctly hold Shift then click ZZ on the keyboard to save this file.

[Unit]
Description=Admiral container
Requires=docker.service
After=docker.service

[Service]
Restart=always
ExecStart=/usr/bin/docker start -a admiral
ExecStop=/usr/bin/docker stop -t 2 admiral

[Install]
WantedBy=default.target

Now enable your service to start at boot time with the following command

systemctl enable docker-admiral.service

Now reboot the Photon OS with the following to verify it works

shutdown now -r

Once the server reboots check the status of the container with the following command

docker ps

Enjoy your container running after a reboot!

Remember sharing is caring!

3 Replies to “How to configure Photon OS to auto start containers at boot time”

  1. how can a company that sells 500 million twinkie a year and more than 100 million loaves of bread a year (among others), still close down altogether?cant it get leaner? slash its size in half? why close entirely? i dont understand.

  2. Could this be used to interrupt or stop a vcenter server appliance from booting up? As I understand it the VCSA 6.5 uses photonOS. Thoughts?

Leave a Reply to vmwareDUDE Cancel reply

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

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.