Lab – Docker

Installing Docker

setup docker user as root to eliminate sudo

Searching for docker images

pull image

run the image

List images

delete image

Containers

Running instance of an image

See all running containers

 

delete container

 

Task

Create a new directory

Create a simple scipt – simple.py:

Create a simple file – Dockerfile

Build the docker image:

 

            docker build ./ -t simple:v1.0

 

list all images:

 

            docker image ls

 

run the image in a container:

 

            docker run simple:v1.0

 

to see the generated file, first find the container id:

 

docker container ls

 

then, print the file content:

 

docker container exec c86ba06875ea cat mylog.log

 

stop the container:

 

docker stop [id]

 

save the container to a file:

 

docker save simple:v1.0 > simp.tar

 

to load it in another machine:

 

            docker load < simp.tar