As I had previously mentioned, I wanted to move some of the services on my local network (web, dhcp, dns) over to containers. I landed at using Docker for this as the main point of my test server is to quickly spin up and spin down different services so that I can test them without a lot of overhead. Docker seemed like the best choice for this use case.

Repository Setup

Firstly, I had to add the docker repository.

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Install Docker

Once I had the repository setup, I simply installed the latest version of Docker.

sudo apt update
sudo apt install docker-ce

This seemed way to easy. Quickly testing that it worked showed that it really was that easy.

sudo docker run hello-world

Post-Setup

Even though this is a dev server, I still want to setup security appropriately. As such, I went ahead and setup a security group and added my user to the group so that I wasn’t using the root user to create docker images.

sudo usermod -aG docker $USER

I had to log out and back in to my ssh session, for this to take effect. Once done, I tested hello-world again but this time without sudo.

docker run hello-world

I also want Docker to start automatically on boot as there are some services I want to create that are always running when the server is powered on.

sudo systemctl enable docker

Test Docker Network

Even though docker is setup and working properly

docker run -it ubuntu bash

This started a minimal install of ubuntu. I wanted to validate that this image had connectivity, so I went ahead and installed ping and hit up google.

apt update
apt install iputils-ping
ping google.com

This worked perfectly, so I went ahead and deleted all the testing containers I had created.

docker rm 4f
docker rm c7
docker rm 53

That’s it for today - super simple install compared to the kvm setup I just went through.

Credits:

Docker Docs has great installation instructions, I just followed along.