
Image And Container in Docker
In Docker, images and containers are fundamental concepts, but they serve different purposes. Here's a clear explanation:
📌 How It Works
- Pull an image from Docker Hub:
docker pull nginx
- List downloaded images:
docker images
- Create & run a container from an image:
docker run -d --name my_nginx -p 8080:80 nginx
- List running containers:
docker ps
- Stop and remove a container:
docker stop my_nginxdocker rm my_nginx
- Remove an image:
docker rmi nginx
🎯 Key Takeaways
- Images are like blueprints; they define what a container should have.
- Containers are running instances of images that can be modified.
- You can create multiple containers from a single image.