DevOps Classroom notes 30/Nov/2025

What does it take to run a container

  • Things to have
    • a docker installed on a system (docker host)
    • docker image
  • Containers generally have server side applications which are accessible over network.
  • Docker supports port forwarding between container networks and host networks
    Preview
  • Examine the following command where we did static port forwarding (on host 8088 — contianer 80)
docker container run -d --name web1 -p 8088:80 nginx
  • Examine the following command where we do dynamic port forwarding
docker container run -d --name web3 -P nginx

Preview

What happens during container creation

  • examine the command docker container run -d --name web4 -P httpd
  • docker checks in the local storage if there is an image called as httpd:latest
  • If the image is not found, it tries to connect to a registry. The default registry is docker hub and then pull the image
  • Once the image is availabe then a container is created

Intention: I want to delete all containers

docker rm -f $(docker ps -a -q)

Intention: I want to delete all images

docker rmi $(docker images -q)

Lets look into what is running inside containers

  • Every container starts by running a command which starts the application inside container
  • Your container will be in running state as long as that comand is running
  • We can set the command while running the container which will be executed as PID 1
  • The ideal first command should start your application and continue to run.

Docker container states

Preview

  • I will create nginx container
    Preview
  • Now lets start the nginx container
    Preview
  • Run => create + start
    Preview
  • stop
    Preview
  • To remove/delete container we need to stop and delete or force the delete.
# stop and delete
docker stop nginx1
docker rm nginx1

# force
docker rm -f nginx2

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 Responsive Web Designing 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