DevOps Classroomnotes 08/Apr/2023

How Isolations are created or How Containers Work

  • Each container is getting a
    • new process tree
    • disk mounts
    • network (nic)
    • cpu/memory
    • users
  • Refer Here for Docker Internals
    Preview

Docker Architecture

Generation 1:

  • This was first gen, Where docker daemon used lxc (a linux kernel feature) to create containers
    Preview

Generation2:

  • Since docker was relying on lxc which was kernel feature, updates to kernel frequently used to break containers created by docker.
  • So docker has created its own component called libcontainer (libc) to create containers.
  • Docker wanted containers to be multi os and lxc was definetly not the way forward.
    Preview
  • Adoption of docker was drastically increased as it was stable.

Generation 3:

  • In this generation, docker engine was revamped from monolith to multi component architecture and the images and containers were according to OCI (open container initiative) image spec and runtime spec.
  • In the latest architecture
  • docker daemon exposes api’s to listen requests from docker client.
  • Passes the requests to containerd. This manages the lifecylcle of container
  • containerd forks a runc process which creates container. once the container is created the parent of the container will be docker shim
    Preview

Creating our first docker container

  • docker container creation:
  • To create container we need some image in this case lets take hello-world
  • The command docker container run hello-world executed
  • What happens
    • docker client will forward the request to docker daemon
    • docker daemon will check if the image exists locally. if yes creates the container by using image
    • if the image doesnot exist, then docker daemon tries to download the image from docker registry connected. The default docker registry is docker hub.
    • Downloading image into local repo from registy is called as pull.
    • Once the image is pulled the container is created.
      Preview
  • Registry is collection of docker images hosted for reuse.
  • Docker hub Refer Here

Playing with containers

  • Create a new linux vm and install docker in it
    Preview
    Preview
  • Open all the ports
    • AWS
      Preview
      Preview
    • Azure
      Preview
      Preview

Check docker images in the host

Preview
Preview
Preview

pull the images from docker hub

  • image naming convention
[username]/[repository]:[<tag>]
shaikkhajaibrahim/myspc:1.0.1
username => shaikkhajaibrahi
repository => what image => myspc
tag => version => 1.0.1
  • default tag is latest
nginx
nginx:latest
  • official images dont have username
nginx
ubuntu
alpine
shaikkhajaibrahim/myspc
  • Lets pull the image nginx with tag 1.23
docker image pull nginx:1.23
docker image ls

Preview
* Lets pull the jenkins image with latest version
Preview
* Lets find the alpine and pull the image
Preview

Remove images from local

  • Every image will have unique image id and image name
  • We can delete individually docker image rm alpine:3.17
  • if i have to delete all the images `docker image rm $(docker image ls -q)
    Preview
    Preview

Create a container with nginx

  • To create and start the container we use run command
    Preview
  • note: i will be using -d for some time and we will discuss importance of this in next session
  • every container gets an id and a name. name can be passed while creating container, if not docker will give random name
    Preview
  • Remove all the running containers docker container rm -f $(docker container ls -q )
    Preview
    Preview
  • Remove specific container
    Preview
  • Remove all containers docker container rm -f $(docker container ls -a -q )
    Preview
  • Exercise: Start and stop containers

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube