Nov 23, 2022

Docker Container 101

Virtualization or hypervisor virtualizes hardware; docker container virtualizes OS kernel.

First, we just start a docker images with Multipass.

PS> multipass launch docker -n kiko

Login to docker and start download the images.

PS> multipass shell kiko

ubuntu@kiko:~$ docker pull centos

ubuntu@kiko:~$  docker container run -itd --name cc centos

ubuntu@kiko:~$ docker exec -it cc bash 

[root@a4d5e22b6ef5 /]# cat /etc/os-release

Try download other images.

ubuntu@kiko:~$ docker pull archlinux 

ubuntu@kiko:~$ docker pull ubuntu

ubuntu@kiko:~$ docker pull almalinux

ubuntu@kiko:~$ docker run -itd --name uu ubuntu

Check the utilization and stop the container.

ubuntu@kiko:~$ docker stats

ubuntu@kiko:~$ docker stop uu cc 

 

Why container runs so fast and why use container?

  • share the kernel with hosts (compare to separate guest OS kernel).
  • use control group to define cpu, mem, disk, network namespaces.
  • container is portable.
  • micro-service concept.


Links: