
Run
docker run <image> to pull an image from the configured registry (Docker Hub by default) if it’s not already present locally. Docker then creates and starts a container from that image. To run in the background, add -d; to map ports use -p, and to assign a container name use --name.docker run command multiple times). In production, place a load balancer in front of instances or use an orchestrator to handle scaling and health checks automatically.
Useful orchestrators and service managers:
- Docker Compose — local multi-container setups: https://docs.docker.com/compose/
- Docker Swarm — Docker’s built-in clustering: https://docs.docker.com/engine/swarm/
- Kubernetes — production-grade orchestration: https://kubernetes.io/
Building and publishing your own images
If a public image doesn’t meet your needs, build a custom image with a Dockerfile and push it to a registry you control:
Be cautious when using public images. Prefer official or verified images, check image sizes and Dockerfile practices, and avoid running untrusted images as root. For private artifacts, use authenticated registries (e.g., ECR, ACR) and secure credentials with your CI/CD system.
- Registries host container images for distribution; Docker Hub is the default but many cloud and private registries exist.
docker runpulls, creates, and starts a container from an image; add flags like-d,-p, and--nameto control behavior.- Images are immutable templates; containers are running instances with writable layers.
- Build and push your own images when public images don’t fit your needs, and use orchestrators to manage scaling and resilience in production.
- Docker Hub: https://hub.docker.com/
- GitHub Container Registry: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry
- Google Artifact Registry: https://cloud.google.com/artifact-registry
- AWS ECR: https://aws.amazon.com/ecr/
- Azure Container Registry: https://azure.microsoft.com/en-us/services/container-registry/
- Docker Compose: https://docs.docker.com/compose/
- Kubernetes: https://kubernetes.io/