Docker and more generic Linux containers technology are a hot topic these days. The website says “for developers and sysadmins”, I am neither of the two but I can still find some useful applications for containers as a Network Engineer .

Let’s start from the basics.

Install docker and first run

We can apt-get to install docker on Ubuntu Linux:

apt-get install docker.io 

Now start docker service:

service docker start

That was easy.

Now we can download an Ubuntu 15.04 container from the official Ubuntu repository :

docker pull ubuntu:15.04

It will take some time, that’s about 130MB.

Pulling repository ubuntu
Status: Downloaded newer image for ubuntu:15.04

Check if the new image is available in the local images list:

docker images

REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
ubuntu              vivid               bd94ae587483        17 hours ago        131.3 MB
ubuntu              vivid-20150427      bd94ae587483        17 hours ago        131.3 MB
ubuntu              15.04               bd94ae587483        17 hours ago        131.3 MB

Run the container and start bash inside of it:

docker run -i -t ubuntu:15.04 /bin/bash

(to exit the container without stopping it: CTRL+P CTRL+Q)

Notice the command prompt changes:

root@c7466ae4d0b1

Good, we’re inside the container now!

A container lives as long it is running the process used to start it, in this case “/bin/bash”.

If you type “exit” now the container would be killed.

To leave the container without closing it type

CTRL+P CTRL+Q

Useful docker commands

List available images:

docker images

List all running containers:

docker ps

Kill a container:

docker kill CONTAINER_ID

Connect to a container:

docker attach CONTAINER_ID

More commands in the Docker User Guide .

In the next post I’ll show you some more advanced Docker configurations and how to add software to a Docker image. Stay tuned!