Docker Container Registries
Container registries are essential services that store and manage Docker images, making it easy to share and deploy containerized applications.
They are like the well-organized libraries of the software world. They store and manage your container images, making it easy for people to access and use your software recipes.
There are various container registries available, each with its own features and benefits. In this blog post, we’ll compare popular registries, including Docker Hub, Quay, GitLab Container Registry, GitHub Container Registry, and Google Cloud Container Registry, to help you determine which registry best suits your needs.
GitLab and GitHub Container Registries are integrated into their respective Git repository management platforms, streamlining the CI/CD process. Google Cloud Container Registry is a Google Cloud Platform service that offers integration with other Google Cloud services and robust security features.
Most registries, such as Docker Hub, Quay, GitLab, and GitHub, offer seamless integration with popular CI/CD tools like Jenkins, Travis CI, and CircleCI.
Google Cloud Container Registry is best suited for users leveraging Google Cloud services, such as Google Kubernetes Engine (GKE), and offers native integration with Google Cloud Build for CI/CD pipelines.
This is why Docker is a game-changer for software development. It takes the headache out of managing dependencies and environment setups, making your life as a developer a whole lot easier.
What is Docker?
Docker uses something called containerization. It’s like having a virtual machine, but it’s super lightweight and efficient. Each container is a self-contained, isolated environment. It has its own file system, libraries, and even its own little world of processes. But it shares the same kernel (the core part of the operating system) with the host machine. This makes Docker containers incredibly efficient and fast.
Imagine you’re sharing your masterpiece with a friend, and they have a different computer setup. Without Docker, you’d have to spend hours, maybe even days, helping them set up their environment just right. But with Docker, your friend can then run your application without any fuss, regardless of their computer’s setup. No more “It works on my machine” excuses!
A container registry is like your library of recipes, but for software containers. It’s a safe, central place to keep your container images, the packaged recipes for your software applications.
Probably the most famous container registry. It is the default registry for Docker and one of the most popular choices.
It offers both public and private repositories, with a free tier available for users.
The images have the following estructure: docker.io/your_dockerhub_user/your_container_name:container_version
- Have a look at it:
- Example image: docker.io/python:latest
Linux Server Container Registry - lscr
Linuxserver.io is a group of like-minded enthusiasts who provide various Docker images for open-source applications. However, Linuxserver.io does not operate its own container registry. Instead, they host their images on Docker Hub, which serves as a registry for their open-source images.
- You can see their amazing content at:
- When pulling images, you will see reference to: lscr.io
Github and Gitlab Container Registries
GitLab and GitHub Container Registries are tightly integrated with their respective platforms, making them a natural choice for users already invested in those ecosystems.
Whenever you will see a yaml configuration file with the image starting by registry.gitlab.com, you can detect that we are pulling the image from this Registry. And of you see ghcr.io you will know that you are pulling an image from Github CR.
For example, we have here one R Shiny container from Gitlab:
--- version: "2" services: shiny_app: image: registry.gitlab.com/analythium/shinyproxy-hello/hello container_name: shiny ports: - 3838:3838 restart: unless-stopped
And another from that uses Github:
version: '3.8' services: route_tracker_streamlit_app: image: ghcr.io/jalcocert/py_routetracker:v1.0 #fossengineer/py_routetracker:v1.0 container_name: py_routetracker ports: - "8509:8501" working_dir: /app command: streamlit run app.py #command: python3 app.py #command: tail -f /dev/null #keep it running
Google Container Registry - GCR
Google Cloud Container Registry provides robust security and reliability but may be more expensive than other options if your usage exceeds the free tier.
Quay, another well-known registry, is owned by Red Hat and provides features such as vulnerability scanning and robust access control.
You can try it at: https://quay.io/
How to Use DockerHub?
Building Docker Images
Building from local files:
#docker build -t your_container_name . #docker image ls #to check the images locally
Pushing Local Images to Container Repositories
After the build, you will need to login to DockerHub and push the image:
#docker build -t your_dockerhub_account/your_container_name . #docker login #docker push your_dockerhub_account/your_container_name
An alternative to this is to use an automatic CI/CD Pipeline, for example with Github Actions, Gitlab CI/CD or some open source tool like Jenkins.
Run your containerized app with:
#docker run -p 8050:8050 your_container_name #docker run --name your_container_INSTANCE_name -p 8050:8050 your_container_name -d