After building beautiful containers and connecting them in networks, it's time to share your hard work. Whether you're working in a team, deploying to servers, or simply backing up your images โ Docker Registries are the way to store and distribute container images across systems.
A Docker registry is a storage and distribution system for named Docker images. It holds versions of images (tags) and allows push/pull access through Docker clients.
Common Registries:
Docker Hub is like GitHub โ but for Docker images. It's the default registry Docker pulls from.
docker login
You'll be prompted for your Docker ID and password. This stores a token in ~/.docker/config.json.
Before pushing, tag it properly with your Docker Hub username:
docker tag myapp aelify/myapp:v1
docker push aelify/myapp:v1
docker pull aelify/myapp:v1
:tags instead of :latest for better version control.Don't want to rely on Docker Hub? You can host your own registry using the official image.
docker run -d \
-p 5000:5000 \
--name registry \
registry:2
This will start a local registry at localhost:5000.
docker tag myapp localhost:5000/myapp
docker push localhost:5000/myapp
docker pull localhost:5000/myapp
Running a private registry in production? You'll need a domain + HTTPS.
server {
listen 443 ssl;
server_name registry.mycompany.com;
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
location / {
proxy_pass http://localhost:5000;
}
}
Tell Docker to trust your registry:
// /etc/docker/daemon.json
{
"insecure-registries" : ["registry.mycompany.com:5000"]
}
Then restart Docker:
systemctl restart docker
Docker stores auth credentials in ~/.docker/config.json. To prevent leakage:
docker logout after pushes on shared systems.pass, osxkeychain, or wincred.Next time someone says "where's your image?", you'll know exactly how to store, tag, push, and secure your Docker builds like a pro ๐ช.
In our next post, we'll dive into ๐ธ (Post 5): Orchestrating Containers with Docker Swarm & Kubernetes Basics!
โ Blog by Aelify (ML2AI.com)
๐ Documentation Index