Docker 🛳
Installation :
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update1. Running a Container
Basic Run Command:
docker run <options> <image>Example: Run a container in detached mode with port mapping:
docker run -d -p 443:443 --name <name> <docker_image_name>-d: Run container in detached mode.-p 443:443: Map port 443 on the host to port 443 on the container.
2. List Running Containers
Command:
Lists all running containers.
3. List All Containers (Including Stopped)
Command:
4. Stopping a Container
Command:
Stops a running container.
Example:
5. Starting a Container
Command:
6. Remove a Container
Command:
7. Remove a Running Container (Force)
Command:
8. Viewing Container Logs
Command:
9. Run a Container with a Specific Command
Example: Running a container with a custom command:
This runs the Ubuntu image and starts the container with the command
sleep 3600(for 1 hour).
10. Building a Docker Image
Command:
Example:
11. List All Docker Images
Command:
12. Remove a Docker Image
Command:
13. Viewing Docker Info
Command:
Displays information about your Docker installation and environment.
14. Accessing a Running Container (Interactive Mode)
Command:
Starts an interactive bash session inside the container.
15. Viewing Docker Version
Command:
16. Remove Unused Docker Resources (Images, Containers, Volumes)
Command:
17. Building and Running a Docker Compose Application
Command:
Starts the services defined in
docker-compose.yml.
18. Stopping All Containers
Command:
19. Accessing a Container's File System
Command:
20. Viewing Docker Container Statistics
Command:
Displays real-time statistics about containers' CPU and memory usage.

Last updated