In our previous blogs, we have been busy in establishing various multi-tier docker architecture, working around docker images and containers and understanding their communication. Although we learnt a great many things and we are ready to explore more complex architectures but I think we have to revisit Docker Basics more often than we do. As with the Docker community keeps updating themselves with optimisation and patches on various levels, we need to get ourselves updated as well. So I decided to discuss Docker installation with Aufs storage diver.
While working on Docker projects, we came across various challenges. As we can’t presume Docker to be perfect for every environment, we had to tweak a little in configurations, override default values. etc that were best for our development.
Zombie Images and Container
One of the frequent occurring problems that I came across is the issues with Orphan (dead) image and containers. Even lots pf people must have faced this issue that Images and containers are still consuming Disk space even after containers are terminated, or images are removed. We call them to be zombie images and containers, still haunting us even after they are presumably gone.
As they were sticking to our disk size, we started exploring storage driver that was deployed for docker storage. We were using overlay storage. We found that even after container and image termination, data was still present in /var/lib/docker/overlay2.
Overlay2 storage has been used as default storage driver now for Docker community edition, but earlier it was the aufs storage that was used as default storage for Docker. So we decided to switch or Storage driver back to aufs. Choosing Aufs storage curbed the orphan images and container problem. So I decided to write a blog on fresh installation of Docker community version on Ubuntu 16.04 with aufs storage.
Docker Installation on Ubuntu 16.04
First of all, update and upgrade your Ubuntu 16.04 server as,
1 2 3 |
apt-get update && apt-get -y upgrade |
As we have already discussed, Docker CE use overlay2 storage by default. To use Aufs storage, we have to install linux-image-extra package for ubuntu 16.04.
1 2 3 |
apt-get install linux-image-extra-`uname -r` |
Now, to add repo from Docker official repository we need to first add key as,
1 2 3 |
sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D |
Proceeding with addition of repository,
1 2 3 |
echo "deb https://apt.dockerproject.org/repo ubuntu-xenial main" | sudo tee /etc/apt/sources.list.d/docker.list |
Now, we have added docker repository. We need to update it before beginning docker installation.
1 2 3 |
apt-get update apt-get install docker-engine |
Check if docker server is running and restart if its not up.
1 2 3 |
/etc/init.d/docker status /etc/init.d/docker restart |
Check the docker details (storage driver as well) by,
1 2 3 |
docker info |
Docker has been installed with Aufs storage driver. We will discuss further regarding changing storage driver without reinstalling the Docker in our later blogs.