Docker
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 | sudo apt update && sudo apt upgrade |
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 | docker pull <image-name> |
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> |