My sample MkDocs site containerized with Docker and served via K8s.
This project demonstrates how to build, containerize, and deploy a static documentation site using MkDocs with the Material for MkDocs theme. It includes Docker and Kubernetes configurations for development and deployment.
- MkDocs
- Material for MkDocs
- Docker
- Kubernetes (via Docker Desktop integration)
- Static documentation site powered by Markdown
- Dockerized/containerized for isolated and reproducible builds
- Kubernetes deployment via manifest (
mkdocs-deployment.yaml) - (Optional) LoadBalancer service configuration (
service.yaml)
mkdocs-devops/
├── docs/ # Markdown content
├── mkdocs.yml # MkDocs config
├── Dockerfile # Docker build setup
├── mkdocs-deployment.yaml # Kubernetes deployment
├── service.yaml # (Optional) Kubernetes service
└── README.md
docker build -t mkdocs-devops .
docker run -p 8000:8000 mkdocs-devopsGo to http://localhost:8000.
-
Push your Docker image to Docker Hub:
docker tag mkdocs-devops yourdockerhubusername/mkdocs-devops docker push yourdockerhubusername/mkdocs-devops
-
Update the image field in the
mkdocs-deployment.yamlto use the image from Docker Hub. -
After updating the
mkdocs-deployment.yaml, apply the changes:kubectl apply -f mkdocs-deployment.yaml
-
Access the site.
If using port-forwarding:
kubectl port-forward deployment/mkdocs-deployment 8000:8000
This will forward port 8000 on your local machine to port 8000 in your container, making the site accessible locally.
Then open your web browser and go to http://localhost:8000.
| Situation | Command | When to use |
|---|---|---|
| First-time deploy | kubectl apply -f mkdocs-deployment.yaml |
When you're initially creating the deployment. |
| Stopping the deployment gracefully | kubectl scale deployment mkdocs-deployment --replicas=0 |
To stop the app without deleting the deployment. |
| Restarting after scaling to zero | kubectl scale deployment mkdocs-deployment --replicas=1 |
When you've previously applied the YAML and just want to start it again. Port forwarding has to be done again. |
- The
service.yamlfile is only required if you're exposing the deployment via LoadBalancer or NodePort. - This repo is a dev-focused demo; production use should involve ingress and TLS.