There are several ways to set up a Docker registry. Here are the most common methods:
Using a public DockerRegistry, like Docker Hub
. It is a hosted registry service provided by Docker, and it's the easiest way to start using a Docker registry. You just need to create an account on Docker Hub and start pushing your images.
Docker provides an official image for setting up your own registry. You can run a private Docker registry on your own server or cloud provider.
Using Docker CLI
docker run -d -p 5000:5000 --name registry registry:2
This command will pull the official registry image and run it as a container on port 5000.
Using Docker Compose
Create a docker-compose.yml
file:
services:
registry:
image: registry:2
ports:
- "5000:5000"
environment:
REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /var/lib/registry
volumes:
- ./data:/var/lib/registry
AWS ECR is a managed container image registry service. You can integrate it with your AWS account and use it to store your Docker images.
Steps:
- Create a repository in AWS ECR.
- Configure your Docker CLI to authenticate with ECR: sh
aws ecr get-login-password --region your-region | docker login --username AWS --password-stdin your-account-id.dkr.ecr.your-region.amazonaws.com
- Tag and push your image:
docker tag your-image:latest your-account-id.dkr.ecr.your-region.amazonaws.com/your-repository:tag
docker push your-account-id.dkr.ecr.your-region.amazonaws.com/your-repository:tag
GCR is a fully managed Docker registry service by Google Cloud Platform.
Steps:
- Authenticate Docker with GCR: sh
gcloud auth configure-docker
- Tag and push your image: sh
docker tag your-image gcr.io/your-project-id/your-image
docker push gcr.io/your-project-id/your-image
ACR is a managed Docker registry service by Microsoft Azure.
Steps:
- Create a registry in Azure.
- Log in to the registry: sh
az acr login --name yourRegistryName
- Tag and push your image: sh
docker tag your-image yourRegistryName.azurecr.io/your-image
docker push yourRegistryName.azurecr.io/your-image
Harbor is an open-source container image registry that secures images with role-based access control, scans images for vulnerabilities, and signs images as trusted.
Using Docker Compose
Create a harbor.yml
file with your configuration.
See at the 06.Harbor for details >>>