Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save akhdaniel/a60c8cb5f7ef9666eb7bf3eaedcde2e8 to your computer and use it in GitHub Desktop.
Save akhdaniel/a60c8cb5f7ef9666eb7bf3eaedcde2e8 to your computer and use it in GitHub Desktop.
make a Docker container start automatically on system boot

create systemctl service file

vim /etc/systemd/system/docker-odoo.service

file content is

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

[Service]
Restart=always
ExecStart=/usr/bin/docker-compose -f <docker-compose-yml-file> start
ExecStop=/usr/bin/docker-compose -f <docker-compose-yml-file> stop

[Install]
WantedBy=default.target

enable service

sudo systemctl enable docker-odoo.service

start service

systemctl start docker-odoo.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment