Docker – 02- Images and Containers

Docker Images vs Containers



I will describe one sentence by OOP

Images are classes

     >Readonly filesystem

Containers are class instances

>Encapsulated set of process running Read-Write copy of that filesystem(image)

By the way

docker run -> starts a container from given image

 We will describe docker images command (build,commit,import)

Images namespaces

Classes are must be under the namespace so images must be

Root like


User (and organizations)



You can see the list of images by this command

docker images

You can search spesific image by

docker search zookeeper

And you can pull images by

docker pull debian:jessie

docker images

You will show downloaded image


Docker – 01-Basics


Note : Docker currently  support x64 cpu platforms and we will use ubuntu server 14.04 64 bit machine


sudo apt-get install

sudo docker version

and we must create docker group for security reason

sudo groupadd docker

sudo gpasswd -a $USER docker

sudo service docker restart

Run Docker Containers

docker run busybox echo Hello

its means create the busybox container with default image and run echo Hello

also we can create ubuntu image

docker run -it ubuntu bash

we can see list of packages

dpkg -l | wc -l

we can see all the containers by this command

docker ps

Container Sample

docker run jpetazzo/clock

if you add -d it will run on backround and it gives the job id

docker run -d jpetazzo/clock

docker ps -q

it will show running container process

if you want to see just container ids

docker ps -aq

And you can see the logs

docker logs <job id>

docker logs –tail 5 <job id>

You can kill or stop this task

docker kill <job id>

docker stop  <job id>

Diffrances between kill and stop?

Kill     -> very quick

Stop ->less than kill