fbpx

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. 🐳

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:

docker --version

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:

docker pull <image-name>

Example:

docker pull hello-world

What it does: Downloads the specified image (like hello-world) from Docker Hub.

Interactive Task: Try pulling the hello-world image:

docker pull hello-world

3. Running a Container ▶️

Command:

docker run <image-name>

Example

docker run hello-world

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:

docker ps

What it does: Shows running containers.

Command (to show all containers, including stopped ones):

docker ps -a

Interactive Task: Run both commands and compare the outputs. Notice the difference when using the -a flag.

5. Stopping a Container ⏹️

Command:

docker stop <container-id>

Example:

docker stop 123abc

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:

docker rm <container-id>

Example:

docker rm 123abc

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:

docker rmi <image-name>

Example:

docker rmi hello-world

What it does: Deletes a Docker image from your system.

Interactive Task: List all images on your system using:

docker images

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! 🐳

DevOps with AWS Training

Take your DevOps skills to the next level with our AWS training! Gain hands-on experience, real-world project exposure, and industry-recognized expertise. Enroll today and step into a high-demand career

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