DevOps Basics: Introduction to Docker Registry and Images


The concept of a Docker container is to build something (your application) on the top of an existing image.

Let’s say for example that you have a Python application and you want to run this application on an Ubuntu image, because you like this distribution 😉

You will have this basic architecture :

I deployed and using an Ubuntu virtual machine on Azure with Docker already installed on it and now I wish to run two different Python applications on it.

Steps to complete this are detailed in the following video:

Images and Registry

The main point of the containerization is that you can build your own images based on existing one, we call that layers but we will talk about this concept on a different article.

It means, in your example, is that you can grab an official Ubuntu image with your Python tools already installed and ready to be used from a common place called a repository.

You have two different repository : Public and Private.

  • The public one is the official from Docker, also called : Docker Hub
  • You can also deploy and maintain your own private repository under your firewall on a container

If you are familiar with Github, we can say that the Docker Hub (Public Repo) is like Github for source code. Is a place where you store your custom images, or pull images from others people.

Let's practice

If you check : https://hub.docker.com/explore/

As you can see you have the list of the most popular one.

Let's try to do a search for something specific like “Flask” for example:


You can click on one image and check the description on what’s inside this image.

If you are a big fan of Ubuntu, you check is the base image that you pick is the good one and go with it.

Alpine

If you are not familiar with the others “Image Base”, I encourage you to check the alpine project.

To keep that simple, this distribution is the lightest one, so for example you just need a image with Python + Flask up and running without all the commands like “Ping” or “Vim” etc… Alpine is the best way to do that.

The amazing about this distribution is the size, if you compare Ubuntu with around 232Mb at the beginning, Alpine will take only around 16Mb …

Tags

When you click on any repositories on Docker Hub, you have a tab called: Tags

let's try to click on it on the official Python image, and you shoul have this output :

As you can see, your images can have different tags and you can choose from this list witch one do you want to use.

Let’s say for example you want the Python Official image on an Ubuntu base, it will be a different tag that if you want the same Python image but on an Alpine base one for example.

Or maybe you want a specific version of Ubuntu, or even a specific version of Python… you can pick thanks to the tags feature.

Command line with the registry

Now that you have the concept of, what is a repository, let me show you the basics command line that you can use in your environment.

The first one is : docker search XXXXXX

For example : docker search python :

You will have basically the same results from the website.

The problem with the search command line is that you cannot see the tags for a specific image…

Let’s say now that you want to pull and use the python image in your Docker environment.

To do that you just have to run the docker pull XXXXXX command

For example : docker pull python

Here I just entered the name of the python image without any tag, that mean my Docker environment will pull the latest one.

You can check the images that you have pull with the following command: docker images

Let’s try now with a specific tag, for example : docker pull python:alpine

If we check again with the docker images command we have now :

You can remark the different size with the alpine one as I told few lines before.

Remove your images

Let’s say that you want make some free space and remove some images that you just downloaded.

You can do that with the following command : docker rmi XXXXX

For example, let’s remove the first Python image that we just downloaded with the docker rmi python command :

If we check our local images we should have now :

Previous contents

I hope you are enjoying this serie about the Docker fundamentals.

If you want to check the previous article :

  • DevOps Basics : Deploying A Simple Docker Environment on Azure
  • DevOps Basics: Introduction to Docker Commands and Concepts

If you have questions, just tweet me 🙂

Thanks

Julien Stroheker / @Ju_stroh

Comments (0)

Skip to main content