Lab – Docker

Installing Docker

# sudo apt install

setup docker user as root to eliminate sudo

# sudo usermod -aG docker ${USER}
# su - ${USER}
# id -nG

Searching for docker images

# docker search ubuntu

pull image

# docker pull ubuntu

run the image

# docker run -it ubuntu

List images

# docker images

delete image

# docker image rm [name]


Running instance of an image

See all running containers

# docker container ls


delete container

# docker container rm [name]



Create a new directory

Create a simple scipt –

import time

while True:
	f.write("simple:" + str(i) + "\n")

Create a simple file – Dockerfile

FROM python:3.7-slim
COPY . /app
CMD python ./

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