Docker Basics (Part 1) : Fundamental Commands

Photo by Seiji Seiji on Unsplash

Docker Basics (Part 1) : Fundamental Commands

Welcome to the world of containerization, where efficiency, scalability, and ease of deployment converge. Docker has revolutionized the way we build, ship, and run applications, offering a robust solution for managing containers seamlessly. In this comprehensive guide, we will delve into the intricacies of Docker, covering fundamental container management, image manipulation, volume handling, network configurations, and the power of Docker Compose.

Docker Basics Full series : Visit Series

Container management

List all running container

docker ps

List all containers including stopped ones

docker ps -a

Run a new container from image

docker run <image name>

Stop running a container

docker stop <container name or ID>

Start a stopped container

docker start <container name or ID>

Pause a running container

docker pause <container name or ID>

Unpause a container

docker unpause <container name or ID>

Info about a container

docker inspect <container name or ID>

Remove a container

docker rm <container name or ID>

Attach to a running container

docker attach <container name or ID>

Excecute a command

docker exec <container name> <command>

Image management

Remove an image

docker rmi <image name or ID>

List all images

docker images

Build an image from a Dockerfile

docker build -t <image name:tag> <path to Dockerfile>

Pull an image from registry

docker pull <image name:tag>

Volume Management:

List all volumes

docker volume ls

Create a volume

docker volume create <volume name>

Remove a volume

docker volume rm <volume name>

Network Management

List all networks

docker network ls

Create a network

docker network create <network name>

Remove a network

docker network rm <network name>

Docker compose

Run container def in Docker compose file

docker-compose up

Stop and remove container

docker-compose down

Did you find this article valuable?

Support Aswin Benny by becoming a sponsor. Any amount is appreciated!