Automatically start docker on reboot of linux machine

Hello,

I’m trying to look out for a way to start the docker container after the linux(centos7) machine is rebooted.
I followed the document where we can use --restart=always flag, but only using this doesn’t work.

On looking around, I saw people using systemd service to keep the docker running.
I am facing issues there also, and want to know if this is the right way?

Thanks :v:t3:

Systemd is for running the docker daemon. If you installed Docker from the official documentation

the daemon should start automatically and that starts the containers.

I’m using Ubuntu 24.04 LTS and had same issue
This is how to auto start Docker Desktop at user login (You must configure your user to auto login)
cd to ~/.config/autostart/
OR
cd /home/username/.config/autostart
If you don’t have a folder named autostart then create one with that name using mkdir autostart.
Create a new file with the name “Docker-Desktop.desktop”
nano Docker-Desktop.desktop
Add the following lines

[Desktop Entry]
Exec=/opt/docker-desktop/bin/docker-desktop
Name=Docker Desktop
Type=Application

Reboot