In this offline lecture, Harkirat covers essential Docker concepts, including Docker commands
, pushing images to Docker Hub
, and using Docker Compose
to define and run multi-container applications, providing practical examples and code snippets throughout.
Docker provides a wide range of commands that allow you to interact with Docker images, containers, networks, and volumes. Here's a brief summary of the most essential Docker commands:
docker run
:
docker run -p 8080:80 nginx
(starts an Nginx container and maps port 8080 on the host to port 80 in the container).docker ps
:
docker ps -a
to list all containers, including stopped ones.docker images
:
docker build
:
docker build -t my-image .
(builds an image tagged as "my-image" using the Dockerfile in the current directory).docker pull
:
docker pull ubuntu
(downloads the latest Ubuntu image from Docker Hub).docker push
:
docker push my-image
(pushes the "my-image" to the configured registry).docker stop
:
docker stop my-container
(stops the container named "my-container").docker start
:
docker start my-container
(starts the container named "my-container").docker rm
:
docker rm my-container
(removes the container named "my-container").docker rmi
:
docker rmi my-image
(removes the image named "my-image").docker exec
:
docker exec -it my-container bash
(starts an interactive Bash shell inside the container named "my-container").docker logs
:
docker logs my-container
(displays the logs of the container named "my-container").docker network
:
docker network create my-network
(creates a new Docker network named "my-network").docker volume
:
docker volume create my-volume
(creates a new Docker volume named "my-volume").