Skip to main content

Command Palette

Search for a command to run...

๐ŸฌDay 20 - Docker Cheat Sheet

Published
โ€ข2 min readโ€ขView as Markdown
๐ŸฌDay 20 - Docker Cheat Sheet
H

๐Ÿ‘จโ€๐Ÿ’ป Passionate PHP WordPress Developer | Embracing DevOps & AWS Enthusiast ๐Ÿš€

Hey there! ๐Ÿ‘‹ I'm Harshit Vishnoi, a dedicated PHP WordPress developer with a fervent enthusiasm for crafting robust and dynamic web solutions. With years of experience in WordPress development, I've honed my skills in creating captivating websites that exceed client expectations.

๐Ÿ”ง Currently, I'm on an exciting journey of exploring the realm of DevOps and AWS. Delving into the intricacies of DevOps methodologies and tools, I'm committed to mastering automation, continuous integration, and infrastructure management to enhance project efficiency and scalability.

๐Ÿ“š Eager to learn and grow, I'm immersing myself in various DevOps tools and practices, including CI/CD pipelines, containerization with Docker, orchestration with Kubernetes, and cloud infrastructure management on AWS.

๐Ÿ’ก Let's connect, collaborate, and innovate together as we navigate the dynamic landscape of web development and DevOps. Feel free to reach out, share insights, or explore opportunities for collaboration. Together, let's leverage technology to build remarkable digital experiences! ๐ŸŒ๐Ÿ’ฌ

Docker is like a super tool that helps developers put their apps in containers. It's great for everyone, whether you're just starting out or want to get better at Docker. This cheat sheet will help you with installing Docker, managing volumes (like extra storage for your containers), handling images (like app blueprints), and doing things with containers (like starting, stopping, and removing them).

๐Ÿ“€ Image Management:

Build an image from a Dockerfile:

docker build -t <image_name> <path_to_Dockerfile>

List all images:

docker images

Pull an image from Docker Hub:

docker pull <image_name>

Remove an image:

docker rmi <image_name>

๐Ÿ“€ Docker Container:

Run a container:

docker run <image_name>

List running containers:

docker ps

List all containers (including stopped ones):

docker ps -a

Start a stopped container:

docker start <container_id>

Stop a running container:

docker stop <container_id>

Remove a container:

docker rm <container_id>

๐Ÿ“€ Docker Volume:

Create a volume:

docker volume create <volume_name>

List volumes:

docker volume ls

Inspect a volume:

docker volume inspect <volume_name>

Remove a volume:

docker volume rm <volume_name>

๐Ÿ“€ Docker Networking:

List networks:

docker network ls

Inspect a network:

docker network inspect <network_name>

Create a network:

docker network create <network_name>

Connect a container to a network:

docker network connect <network_name> <container_id>

Disconnect a container from a network:

docker network disconnect <network_name> <container_id>

๐Ÿ“€ Docker Compose:

Start containers defined in a Compose file:

docker-compose up

Stop containers defined in a Compose file:

docker-compose down

Build and start containers (with rebuilding if needed):

docker-compose up --build

List containers managed by Compose:

docker-compose ps

Restart containers:

docker-compose restart

Stop and remove containers:

docker-compose down --volumes

This cheat sheet covers essential Docker commands for image management, container operations, volume handling, networking, and Docker Compose usage. Feel free to refer back to it whenever you need a quick reference!

More from this blog

Harshit Vishnoi's blog

25 posts