LaBlog

🐳 Docker Commands for Beginners

10/4/2024

Docker Start

systemctl start docker # Linux open -a Docker # macOS

Docker Version Control

docker --version

Container Commands

Listing running containers --> docker ps List all containers (Running and Stopped) --> docker ps -a Running a Container --> docker run Running a Container in Detached Mode --> docker run -d Running a Container with port assignment --> docker run -p : Stopping Container --> docker stop Restarting the stopped Container --> docker start Deleting the stopped container --> docker rm

Images Commands

Listing Docker images --> docker images Pulling an image via Docker Hub --> docker pull Creating image from Dockerfile --> docker build -t . Tagging the image --> docker tag : Deleting image --> docker rmi

Container Management

Viewing Container Logs --> docker logs Accessing the running Container(Interactive Shell) --> docker exec -it /bin/bash Copying files from Container to Machine --> docker cp :

Docker Networks Commands

Listing Networks --> docker network ls Creating a Network --> docker network create Connecting a Network to a Running Container --> docker network connect

Docker Compose

Starting a Service in Detached Mode --> docker-compose up -d Stopping services --> docker-compose down Create and launch container --> docker-compose up --build

Audit and Monitoring

Inspecting Container Details --> docker inspect Examining Resource (CPU, Memory) Usage --> docker stats

Docker Volumes

Volume Listing --> docker volume ls Creating Volume --> docker volume create Mounting Volume --> docker run -v :

💡 PRO TIP

Use the ''docker system prune'' command to remove unused containers, networks and images.