A hands-on Docker reference covering Docker commands, images, containers, Dockerfiles, networking, volumes, cleanup, Docker Compose, installation, multi-stage builds, and containerized application patterns.
This repository is a practical companion for DevOps and cloud engineers who want reusable Docker examples rather than only theory.
- Docker CLI fundamentals
- Images and containers
- Dockerfile patterns and multi-stage builds
- Container networking
- Volumes and persistent data
- Docker Compose
- Nginx and Java/Spring Boot examples
- Docker cleanup and disk-space management
- Container troubleshooting
- Image optimization and security practices
| Area | Path |
|---|---|
| Docker commands | docker-commands.md |
| Docker installation | docker_installation.md |
| Ubuntu installation | docker_installation_ubuntu.md |
| Networking | Docker Networks |
| Volumes | docker volumes.md |
| Cleanup | docker cleanup commands |
| Docker Compose | docker-compose/ |
| Dockerfile examples | Dockerfile's/ |
| Security guide | docs/security.md |
| Troubleshooting | docs/troubleshooting.md |
| Image optimization | docs/image-optimization.md |
Check your installation:
docker --version
docker infoRun a container:
docker run --name nginx-demo -d -p 8080:80 nginx:alpine
docker psOpen http://localhost:8080.
Inspect logs and clean up:
docker logs nginx-demo
docker stop nginx-demo
docker rm nginx-demoExample:
FROM nginx:alpine
COPY ./website /usr/share/nginx/html
EXPOSE 80Build and run:
docker build -t my-web-app:1.0 .
docker run --name my-web-app -d -p 8080:80 my-web-app:1.0Modern Docker installations use the docker compose command.
docker compose up -d
docker compose ps
docker compose logs -f
docker compose downSee docker-compose/ for the application/database example.
docker network ls
docker network create app-net
docker network connect app-net <container>
docker network inspect app-net
docker network disconnect app-net <container>Use user-defined networks when containers need reliable service-to-service communication.
Named volumes persist data beyond a container lifecycle:
docker volume create app-data
docker run --rm -v app-data:/data alpine sh -c 'echo hello > /data/message.txt'
docker run --rm -v app-data:/data alpine cat /data/message.txtSee docker volumes.md.
The repository contains Java and frontend multi-stage examples that separate build dependencies from the runtime image.
Typical pattern:
FROM maven:3.9-eclipse-temurin-17 AS build
WORKDIR /app
COPY pom.xml .
RUN mvn -q -DskipTests dependency:go-offline
COPY src ./src
RUN mvn -q -DskipTests package
FROM eclipse-temurin:17-jre
WORKDIR /app
COPY --from=build /app/target/app.jar app.jar
ENTRYPOINT ["java", "-jar", "app.jar"]Inspect disk usage first:
docker system dfThen use targeted cleanup:
docker container prune
docker image prune
docker volume prune
docker network pruneUse broad pruning carefully because unused resources may still be needed later.
Docker basics
-> Images & containers
-> Dockerfiles
-> Networking
-> Volumes
-> Compose
-> Multi-stage builds
-> Security & optimization
-> CI/CD
-> Kubernetes
- DevOps engineers
- Cloud engineers
- SREs
- Developers learning containerization
- Docker beginners
- Engineers preparing for Docker/Kubernetes interviews
Practical improvements, corrections, new examples, and documentation updates are welcome.
See CONTRIBUTING.md.
Never commit passwords, API keys, access tokens, private keys, registry credentials, or real environment files.
See SECURITY.md.
If this repository helps you learn Docker or solve a containerization problem, consider giving it a star. It helps other engineers discover the material and motivates continued improvements.
Sandeep Komal
Cloud / DevOps Engineer focused on AWS, Kubernetes, Terraform, CI/CD, automation, and DevSecOps.
- GitHub: @SandeepKomal