This document describes the steps for setting up docker
and docker-compose
on a Linux system. It supports Ubuntu and CentOS like flavors.
Create a file /var/tmp/init-docker.sh
with the following contents
Run this file with as a non-root user who can has sudo privileges
./init-docker.sh
Enable docker to run at startup
Ubuntu
systemctl --user enable docker
Centos / Amazon Linux
sudo service docker start
sudo chkconfig docker on
Allow Docker processes to be long-running that does not get terminated on User-shell logout
By default, users cannot set user services to run at boot time. The admin must enable this on an individual basis for each user.
From the documentation:
Enable/disable user lingering for one or more users. If enabled for a specific user, a user manager is spawned for the user at boot and kept around after logouts. This allows users who are not logged in to run long-running services. Takes one or more user names or numeric UIDs as argument. If no argument is specified, enables/disables lingering for the user of the session of the caller.
sudo loginctl enable-linger $(whoami)
Prevent Docker daemon crashes to terminate the processes.
By default, when Docker daemon terminates, it shuts down running containers. You can configure the daemon so that containers remain running if the daemon becomes unavailable. This functionality is called live restore. The live restore option helps reduce container downtime due to daemon crashes, planned outages, or upgrades.
grep -i "live-restore" /etc/docker/daemon.json || (\\
echo '{"live-restore": true}' | sudo tee /etc/docker/daemon.json && \\
sudo systemctl reload docker && \\
systemctl --user reload docker)