Skip to content

Latest commit

 

History

History
73 lines (35 loc) · 1.42 KB

3.running_container.md

File metadata and controls

73 lines (35 loc) · 1.42 KB

Running containers = containerized processes

  1. Namespaces

    1.1 Network namespace

    In the first terminal:

     docker run -d --name=nginx nginx
    

    In the second terminal:

     docker run --network container:nginx -it alpine:3.19 /bin/sh
    

    in the container:

         apk add curl
    
         curl localhost
    

    and we don't have any nginx running

         ps aux
    

    In the third terminal, we can run another container in a new network namespace (and we want it to be a privileged container):

     docker run --privileged -it alpine:3.19 /bin/sh
    

    In the first terminal:

     docker logs nginx
    
     docker stop nginx
    

    After stop, if we try again curl it will not work anymore

    1.2 Time namespace

    In all the terminals get the current date and time:

     date
    

    Set a new time in the third terminal:

     date +%T -s "18:50:13"
    

    And again in all the terminals get the current date and time:

     date
    
  2. cgroups and chroot

    • no demos
  3. Docker daemon to containerd to runc

    docker run -it alpine:3.19 /bin/sh and run sleep 180 in the container

    docker run -it --pid=host ubuntu:20.10 /bin/sh and then inside the container run:

     apt-get update
    
     apt-get install -y psmisc
    
     ps -fC sleep #it will allow to the the sleep PID
    
     pstree -sg sleep_PID
    
     ps aux | grep docker