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
  • 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
  • Detached
    • Docker container runs in the background
    • add -d to container run to set this mode
    • Example: docker container run -P -d jenkins
  • 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

Experiment with docker command line

  • Execute docker container --help

Leave a ReplyCancel reply

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

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Exit mobile version
%%footer%%