Docker – 02- Images and Containers

Docker Images vs Containers

docker-image

 

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

ubuntu

User (and organizations)

apocoder/clock

Self-Hosted

registry.example.com:5656/my-private-image

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

Advertisements

Docker – 01-Basics

large_v-trans

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

Installation

sudo apt-get install docker.io

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