What is Docker

The new buzz word going around is Docker and it is a big buzzword for a reason. Docker is a powerful tool that can be thought about as a virtual machine. It is not a virtual machine but an “emulator” of different Linux distros. Think of it this way. If you have Fedora we would run the command yum to update, you could create a Docker container to run Debian and update using its container by running apt. Another difference is the size of the container. A VM can be upwards of Gigabytes because it has to have the operating system installed and visualizer the hardware. Docker does not do this, it utilizes the hardware already on the system. This is easily accomplished because at the root of it all Linux runs ruffly the same kernel and just as binary’s that change the way it is used.

Let’s create a simple container

pi@raspberrypi:docker-test $ ls
Dockerfile
pi@raspberrypi:~/docker-test $ sudo docker build .
Sending build context to Docker daemon  2.048kB
Step 1/2 : FROM debian
latest: Pulling from library/debian

ec26d49abcad: Pulling fs layer

ec26d49abcad: Downloading  2.241MB/43.81MB
ec26d49abcad: Extracting  42.66MB/43.81MB
ec26d49abcad: Pull complete
Digest: sha256:5fafd38cdee6c7e6b97356092b97389faa0aa069595f1c3cc3344428b5fd2339
Status: Downloaded newer image for debian:latest
 ---> 8401d69fdde8
Step 2/2 : CMD /bin/echo Hello World
 ---> Running in c23645ab4049
 ---> 8adcef220ed4
Removing intermediate container c23645ab4049

As you can see above our simple image is only 43.81MB big this is so small in comparison

Running a container

Let’s run the container and see how intensive it is.

%Cpu(s):  9.7 us,  7.7 sy,  0.0 ni, 81.3 id,  1.3 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem:    945512 total,   645252 used,   300260 free,    54260 buffers
KiB Swap:   102396 total,        0 used,   102396 free.   486964 cached Mem

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND
  746 root      20   0  930688  54012  24700 S   6.9  5.7  18:21.21 dockerd
    1 root      20   0   22896   3940   2740 S   2.3  0.4   0:07.33 systemd
  840 root      20   0  886916   9128   6076 S   2.3  1.0   9:52.37 docker-containe

Running docker on the Pi 3 we can see it is taking a total of 11% of the memory and 68MB of memory

Leave a Reply

Your email address will not be published. Required fields are marked *