Hey AMChannel Community! Let’s demystify Docker commands with some practical examples for our tech beginners.
1. Pulling an Image:
docker pull nginx
Pull the latest Nginx image from Docker Hub. (Before pulling image make sure you’re login to your Docker hub Account.)
2. Running a Container:
docker run -d -p 8080:80 --name mynginx nginx
Launch a detached Nginx container, mapping port 8080 on your host to port 80 in the container, and giving it the name “mynginx.”
3. Listing Containers:
docker ps
List running containers.
4. Stopping a Container:
docker stop mynginx
Gracefully stop the “mynginx” container.
5. Removing a Container:
docker rm mynginx
Remove the stopped “mynginx” container.
6. Building an Image:
Create a simple Dockerfile (e.g., Dockerfile
) with:
FROM alpine
CMD ["echo", "Hello, Docker!"]
Build the image:
docker build -t myimage .
Make sure you don't miss the dot [.] after the command.
7. Viewing Images:
docker images
List all images on your system, including “myimage.”
8. Cleaning Up:
docker system prune
Remove dangling images, stopped containers, and more.
Remember, practice makes perfect! Dive into these examples, tweak them, and explore the endless possibilities of Docker.
The number of hurdles you get while practicing, you’ll understand and remember the concepts easily.
Share your favorite Docker commands or tips for beginners in the comments! 🤓💻
#Docker #Beginners #DevOps #Containerization