Starting a Container using systemd
Request a new translation or translation update
A translation for your language preference does not exist. Click below to request a translation for your selected language.
To start a container automatically at boot time, first configure it as a systemd service by creating the unit configuration file in the /etc/systemd/system/ directory. For example, the contents of the /etc/systemd/system/redis-container.service can look as follows:
[Unit]
Description=Redis container
Author=Me
After=docker.service
[Service]
Restart=always
ExecStart=/usr/bin/docker start -a redis_server
ExecStop=/usr/bin/docker stop -t 2 redis_server
[Install]
WantedBy=local.target
After creating the unit file, use the systemctl enable command to start the container automatically.
To learn more about configuring services with systemd, refer to chapter called Managing Services with systemd in Red Hat Enterprise Linux 7 System Administrators Guide.
This solution is part of Red Hat's fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.