Docker
Kothandaraman Kannadasan Lv3

Definition

Docker is an open-source platfom used to build, test and deploy the work accorss the teams. It used to create the image with necessary libraries and run them on the containers.

  • Docker Hub

  • Docker Image

  • Docker Container

  • Docker Registry

  • Docker Compose

1. Installing Docker

1
2
3
sudo apt update && sudo apt upgrade
sudo apt install docker.io
docker --version

2. Basic Docker Commands

Pull an image from docker hub

Docker images are templates for containers. Pull an image from Docker Hub (a public registry):

1
docker pull
1
2
docker pull <image-name>
# ex: docker pull ubuntu:20.04

Run a container

Start a container from an image:

1
docker run <image-name>

To run in detached mode (in the background), use the -d flag:

1
docker run -d <image-name>

List running containers

View all running containers:

1
docker ps

To see all containers (including stopped ones):

1
docker ps -a

Stop a container

Stop a running container:

1
docker stop <container-id>

Remove a Container

Delete a stopped container:

1
docker rm <container-id>

Remove an Image

Delete an image:

1
docker rmi <image-name>