DevOps Classrom Series – 25/Jun/2020

Docker Internals

Docker Container (Contd..)

  • Execute the following command
docker container run --help
docker container --help
  • To remove all the containers
docker container rm -f $(docker container ls -a -q)

Portforwading

  • To access the app on the container we use port forwarding Preview
  • To acheive this in command line
    • Assign dynamic port on host.
    docker container run -P <image>
    docker container run -P -d jenkins
    docker container ls
    
    • Assign a specific port on host
    docker container run -p <hostport>:<containerport> <image>
    docker container run -p 80:8080 -d jenkins
    docker container ls
    

Docker container modes

  • Attached :
    • Container runs in the foreground
    • Default mode of docker
    • Example: docker container run -P jenkins Preview
  • Detached
    • Docker container runs in the background
    • add -d to container run to set this mode
    • Example: docker container run -P -d jenkins Preview
  • Interactive
    • In this mode we can interact with docker using terminal (/bin/bash, /bin/sh)
    • add -it to container run to set this mode
    • Example docker container run -it -P jenkins /bin/bash Preview

Experiment with docker command line

  • Execute docker container --help

Leave a Reply

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

About learningthoughtsadmin