Docker is moving fast and Ubuntu’s long term support (LTS) policy doesn’t keep up. To work around this we’ll install a PPA that will get us the latest version of Docker.
Add the upstream Docker repository package signing key. The apt-key command uses elevated privileges via sudo, so a password prompt for the user’s password may appear:
curl -L https://get.docker.com/gpg | sudo apt-key add -
Note: Enter your sudo password at the blinking cursor if necessary.
Add the upstream Docker repository to the system list:
echo deb http://get.docker.io/ubuntu docker main | sudo tee /etc/apt/sources.list.d/docker.list
Update the package list and install the Docker package:
sudo apt-get update && sudo apt-get install -y lxc-docker
Add your user to the docker group to enable communication with the Docker daemon as a normal user, where sammy is your username. Exit and log in again for the new group to take effect:
sudo usermod -aG docker sammy
After re-logging in verify the group membership using the id command. The expected response should include docker like the following example:
uid=1001(test0) gid=1001(test0) groups=1001(test0),27(sudo),999(docker)
Optional: Run bash in a simple Debian Docker image (–rm to clean up container after exit and -it for interactive) to verify Docker operation on host:
docker run --rm -it debian:jessie bash -l
Expected response from docker as it pulls in the images and sets up the container:
Unable to find image ‘debian:jessie’ locally
debian:jessie: The image you are pulling has been verified
511136ea3c5a: Pull complete
36fd425d7d8a: Pull complete
aaabd2b41e22: Pull complete
Status: Downloaded newer image for debian:jessie
Once inside the container you’ll see the root@:/# prompt signifying that the current shell is in a Docker container. To confirm that it’s different from the host, check the version of Debian running in the container:
Expected response for the OpenVPN container at the time of writing:
Debian GNU/Linux jessie/sid
If you see a different version of Debian, that’s fine.
Exit the container by typing logout, and the host’s prompt should appear again.