Chapter 3: Docker Images and Containers
Chapter 3 of 15
Chapter 3: Docker Images and Containers
3.1 Understanding Images
Images are read-only templates used to create containers.
Image Layers:
- Images consist of multiple layers
- Layers are cached for efficiency
- Only changed layers are rebuilt
3.2 Working with Containers
Containers are running instances of images.
# Run container
docker run -d -p 8080:80 nginx
# Execute command in container
docker exec -it container_id bash
# View container logs
docker logs container_id
3.3 Image Management
docker build -t myapp:1.0 . # Build image
docker tag myapp:1.0 myapp:latest # Tag image
docker push myapp:1.0 # Push to registry
docker rmi image_id # Remove image