Last updated 2018-03-03
Install Docker Community Edition
I am working on a clean CentOS 7 VM clone, so I don’t need to remove old versions, but I do need to set a new hostname.
echo docker-centos7.stma | sudo tee /etc/hostname
sudo hostname -F /etc/hostname
From the Docker Docs.
sudo curl -L https://download.docker.com/linux/centos/docker-ce.repo -o /etc/yum.repos.d/docker-ce.repo
sudo yum update
sudo yum install device-mapper-persistent-data docker-ce lvm2
sudo systemctl enable docker
Note that sudo systemctl
is aliased to sctl
in my bashrc.
Generate the initial directories
sudo systemctl start docker
sudo systemctl stop docker
Configure the OverlayFS storage driver
From the Docker Docs.
sudo vim /etc/docker/daemon.json
{
"storage-driver": "overlay2",
"storage-opts": ["overlay2.override_kernel_check=true"],
...
}
In Arch Linux
The Arch Wiki has a different method of setting the options, using a Drop-in Snippet.
sudo systemctl edit docker
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H fd:// -s overlay2
Set up user privileges
Don’t do this for untrusted users. As detailed in the Docker Docs, it’s equivalent to giving a user full root access.
sudo usermod -aG docker stick
Set up remote access
sudo vim /etc/docker/daemon.json
{
...
"hosts": ["tcp://0.0.0.0:2375"],
...
}
The Docker Docs mention RHEL and CentOS overriding the hosts array, but I found that was not true in current CentOS 7. However, I did find that including "fd://"
in the "hosts"
array causes docker to fail on startup.
In Arch Linux
The Arch Wiki has a different method of setting the options, using a Drop-in Snippet.
sudo systemctl edit docker
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock -s overlay2
Try it out
docker run hello-world
Optional: Take a snapshot
history -c
- Close -> ACPI Shutdown
- Snapshots -> Take