Back to Engineering Notes
DockerEngineering Note

4. Docker Essentials Cheat Sheet

Create a new tag for an existing image (no duplication)

๐ŸŽฏ Objective

Quick reference for:

Image tagging
Image creation & deletion
Network creation & deletion
Running containers with volume & port mapping

# ๐Ÿท๏ธ Docker Tag (Image Re-tagging)

๐Ÿง  Concept

Create a new tag for an existing image (no duplication)

โš™๏ธ Command

plain text
docker tag <source_image>:<tag> <target_image>:<tag>

๐Ÿ“Œ Example

plain text
docker tag app:latest app:custom

# ๐Ÿ“ฆ Docker Image Creation

๐Ÿง  Concept

Create image from a container snapshot

โš™๏ธ Command

plain text
docker commit <container_name> <image_name>:<tag>

# ๐Ÿ—‘๏ธ Docker Image Deletion

โš™๏ธ Command

plain text
docker rmi <image_name>:<tag>

โš ๏ธ If in use

plain text
docker rm -f <container_name>
docker rmi <image_name>:<tag>

# ๐ŸŒ Docker Network Creation

๐Ÿง  Concept

Custom network for container communication

โš™๏ธ Command

plain text
docker network create \
--driver bridge \
--subnet <subnet> \
--gateway <gateway> \
  <network_name>

# ๐Ÿ—‘๏ธ Docker Network Deletion

โš™๏ธ Command

plain text
docker network rm <network_name>

โš ๏ธ If in use

plain text
docker network disconnect <network_name> <container_name>
docker network rm <network_name>

# ๐Ÿš€ Run Container (Volume + Port Mapping)

๐Ÿง  Concept

vย โ†’ host โ†” container file sync
pย โ†’ expose container service

โš™๏ธ Command

plain text
docker run-d \
--name <container_name> \
-p <host_port>:<container_port> \
-v <host_path>:<container_path> \
  <image_name>:<tag>

๐Ÿ” Verify

plain text
docker ps
docker inspect <container_name> | grep -A 10 Mounts
docker port <container_name>
curl http://localhost:<host_port>/

# ๐Ÿงช Validation Checklist

[ ] Image tagged correctly
[ ] Image created from container
[ ] Image deleted successfully
[ ] Network created with correct subnet
[ ] Network deleted properly
[ ] Container running with correct port mapping
[ ] Volume mapping working
[ ] Service accessible via curl