Docker

Docker Command

🐳 Docker Command Cheat Sheet

🐳 Docker Command Cheat Sheet 🔢 Basic Docker Commands 1 .docker –version Use Case: Verify Docker installation and version. Example: docker –version Output: Docker version 24.0.5, build ced0996 2. docker info Use Case: Display system-wide information about Docker installation. Example: docker info Output: Containers: 3Running: 1Paused: 0Stopped: 2Images: 10… 3. docker help Use Case: List available Docker commands and options. Example: docker help Output: Usage:  docker [OPTIONS] COMMAND … 🚀 Container Management 1. docker ps Use Case: List running containers. Example: docker ps Output: CONTAINER ID      IMAGE    COMMAND      STATUS      NAMESabc123                     nginx       …                        Up 5s         mynginx 2.docker ps -a Use Case: List all containers, including stopped ones. Example: docker ps – a Output: CONTAINER ID      IMAGE    COMMAND         STATUS                                NAMESabc123                     nginx       …               Exited (0) 2 minutes ago         mynginx 3. docker stop < container_id > Use Case: Stop a running container. Example: docker stop abc123 Output: abc123 4. docker start < container_id > Use Case: Start a previously stopped container. Example: docker start abc123 Output: abc123 5. docker restart < container_id > Use Case: Restart a container (stop and start). Example: docker restart abc123 Output: abc123 6. docker rm < container_id > Use Case: Remove a stopped container from the system. Example: docker rm abc123 Output: abc123 7. docker logs < container_id > Use Case: View logs for a container. Example: docker logs abc123 Output: Starting nginx… Ready to serve requests 8. docker exec -it < container_id > bash Use Case: Access the shell of a running container. Example: docker exec -it abc123 bash Output: root@abc123:/# 🌀 Image Management 1. docker images Use Case: List all Docker images available locally. Example: docker images Output: REPOSITORY       TAG          IMAGE ID               CREATED           SIZEnginx                       latest      abcdef123456     3 days ago       133MB 2. docker pull < image_name > Use Case: Download an image from Docker Hub. Example: docker pull nginx Output: Using default tag: latestlatest: Pulling from library/nginx…Digest: sha256:…Status: Downloaded newer image for nginx:latest 3. docker rmi < image_name > Use Case: Remove a local Docker image. Example: docker rmi nginx Output: Untagged: nginx:latestDeleted: sha256:… 4. docker build – t < image_name > . Use Case: Build a Docker image from a Dockerfile. Example: docker build -t myapp . Output: Successfully built abcdef123456Successfully tagged myapp:latest 🛠️ Running Containers 1. docker run < image_name > Use Case: Run a container from an image. Example: docker run nginx Output: … (nginx process logs) 2. docker run -d < image_name > Use Case: Run a container in the background (detached mode ). Example: docker run -d nginx Output: abc123456789… 3. docker run –name < name > < image > Use Case: Assign a name  to the container  Example: docker run –name mynginx nginx Output: … (container output) 4. docker run -p 8080:80 < image > Use Case: Expose a container port to the host. Example: docker run -p 8080:80 nginx Output: … (nginx running and accessible at localhost:8080) 5. docker run -v /host/path:/container/path < image > Use Case: Mount host directory into the container. Example: docker run -v /tmp:/data nginx Output: … (container starts and has access to /data) 6. docker run –rm < image > Use Case: Automatically remove the container once it stops. Example: docker run –rm hello-world Output: Hello from Docker! … 🌐 Networking 1. docker network ls Use Case: List all Docker networks. Example: docker network ls Output: NETWORK ID       NAME               DRIVER           SCOPEabc123                   bridge              bridge             local     . . .  2.docker network create < network_name > Use Case: Create a new custom network. Example: docker network create mynet Output: mynet 3. docker network inspect < network_name > Use Case: Inspect detailed information about a network. Example: docker network inspect mynet Output: [     {           “Name”: “mynet”,           “Id”: “…”,            “Containers”: {},             …      }] 4. docker network connect < network_name > < container_name > Use Case: Connect a container to a network. Example: docker network connect mynet mynginx Output: (no output if successful) 5. docker network disconnect <network_name> <container_name> Use Case: Disconnect a container from a network. Example: docker network disconnect mynet mynginx Output: (no output if successful) 📁 Volumes & Storage 1. docker volume ls Use Case: List all docker volumes Example: docker volume ls Output: DRIVER     VOLUME NAMElocal            myvolume 2. docker volume create < volume_name > Use Case: Create a new volume Example: docker volume create myvolume Output: myvolume 3. docker volume inspect < volume_name > Use Case: View detailed info about a volume. Example: docker volume inspect myvolume Output: [     {           “Name”: “myvolume”,           “Driver”: “local”,             …      }] 4. docker volume rm < volume_name > Use Case: Delete a Volume  Example: docker volume rm myvolume Output: myvolume 📄 Docker Compose 1. docker-compose up Use Case: Start services defined in a  docker-compose.yml. Example: docker-compose up Output: Starting  myapp  … done… 2. docker-compose up -d Use Case:Start services in detached mode. Example: docker-compose up -d Output: Creating network “myapp_default” with the default driverCreating myapp … done 3. docker-compose down Use Case: Stop and remove all services and resources created by Compose. Example: docker-compose down

Docker Commands for Beginners

Docker Commands for Beginners 🚀 If you’re new to Docker, learning the commands can feel overwhelming. Don’t worry! This interactive blog will guide you through essential Docker commands step-by-step, with simple examples to get you started. 🐳 https://youtu.be/LH4Gqts_l6A?si=X3lwY481h_LPCNwr What is Docker? 🤔 Docker is a platform that enables developers to package applications into containers—lightweight, portable, and self-sufficient units that run consistently across various environments. Containers make it easier to develop, deploy, and scale applications. Prerequisites ✅ Before diving into the commands, make sure: Docker is installed on your system. Install Docker here You have basic knowledge of terminal/command-line usage. 1. Checking Docker Installation 🛠️ Command: What it does: Verifies if Docker is installed and shows the installed version. Interactive Task: Run the command above in your terminal. If Docker is installed, note the version. 2. Pulling an Image 📥 Command: Example: What it does: Downloads the specified image (like hello-world) from Docker Hub. Interactive Task: Try pulling the hello-world image: 3. Running a Container ▶️ Command: Example What it does: Creates and runs a container from the specified image. Interactive Task: Run the hello-world container and observe the output. 4. Listing Containers 📋 Command: What it does: Shows running containers. Command (to show all containers, including stopped ones): Interactive Task: Run both commands and compare the outputs. Notice the difference when using the -a flag. 5. Stopping a Container ⏹️ Command: Example: What it does: Stops a running container. Interactive Task: Use docker ps to find a running container, then stop it using its container ID. 6. Removing a Container 🗑️ Command: Example: What it does: Deletes a stopped container. Interactive Task: List all containers using docker ps -a. Remove one of the stopped containers. 7. Removing an Image 🖼️ Command: Example: What it does: Deletes a Docker image from your system. Interactive Task: List all images on your system using: Then, remove an image you no longer need. Next Steps 🚀 Now that you’ve learned the basics, try exploring more advanced Docker commands, like: docker-compose docker exec docker network Docker’s official documentation is a great place to dive deeper: Docker Docs.Happy Dockering! 🐳https://srtechops.com/wp-content/uploads/2025/01/Remainder-App-Technology-Logo.mp4 Devops Multi cloud Training Choose the training style that fits your schedule — Self-Paced or Live Interactive Sessions. Both include hands-on projects, expert support, and lifetime access. Feature Self-Paced Training Live Training 🎯 Mode 🎥Pre-Recorded Session 🧑‍🏫Live Class + Recordings 💼 Projects 🕒 Weekend Real-Time Projects 📅 Weekdays + Weekend Real-Time Projects ❓ Doubt Clearing 📞 Weekend Live Support Session 🧠 Anytime Doubt Clearing Session 👥 Career Support & Mentorship ❌ No ✅ Yes 🎓 Global Certification Training ❌ No ✅ Yes 🔑 Access ♾️ Lifetime Access ♾️ Lifetime Access 💰 Fees ₹4,999 (2 x ₹2,500) ₹7,999 (2 x ₹4,000) ℹ️ For More Info Explore Self-Paced Training Explore Live Training

Open chat
Hello, Good day!!
How can we help you?