In this lecture, I will show you how to build the image and store it in a registry.
But first I will explain what registry actually is.
Registry is where we store the Docker images that have been built by others, like the airflow docker
image, which we just mentioned in the previous lecture.
And we can also build and store images that we create.
In our case, we will use Docker Hub to store our image, which again is a very popular image registry.
So before we go to the next steps make sure that you have Docker Hub account.
I will put the link to the website in the appendix of this section.
And I will show you how it looks like.
This is the actual Docker Hub URL.
While creating the Docker Hub account, make sure that you store the username and password somewhere
secure and that you can easily retrieve them as we will be using them soon.
So let me sign in.
I am signed in with my account and now we can go to repositories and from here we create the repository.
So for the repository name give it a meaningful name.
In my case I will name it YouTube API underscore LTE and you can name it the same.
You can also add the short description if you want.
In my case, I will leave it blank and then you can select between private or public.
I will select public and I recommend you do the same.
Press create.
And there you have it.
Now you can go back to VS code.
And you can type in docker login command.
So docker login minus you and your username in my case.
You will be prompted for a password.
And if you give it the right password you will see that the login is succeeded.
If you don't get login succeeded, make sure that you are inputting the right username and the password.
And from here we can run the docker build command.
And we will also use the dash t flag for tagging of the image.
So let me show you how it looks like.
Here we specify the username.
And here we specify the repository name.
Tags are a good practice to use as you can specify the version environment, stability and other properties.
In our case we will only use it to track the version.
This version one point 0.0.
The final dot that you see in the command refers to the build context, which is the current directory.
This tells Docker to look for the docker file and any files to be copied from the current directory.
Let's run the command.
So we press enter.
This will take some time depending on the base image how big it is, which for airflow is definitely
not a lightweight image.
We'll come back when it has completed the build successfully.
As you can see here, the build has completed.
You can see some of the Docker file commands which we wrote have also been executed.
So what remains is we actually push the Docker image that we We created to our repository.
For this, we use the docker push command again to specify the username and the repository name.
Also, we specify the tag 1.0.0.
This will also take some time, so we will come back when it has finished.
Okay, it seems that it has completed and pushed the image.
So if we go back to Docker Hub in our repository, we should see the image that we just pushed.
Let's refresh.
And there we have it.
This is the image that we just pushed.
And that's it.
You have successfully built and pushed your own custom Docker image.
That's all for now.
In the next lectures we will go over the airflow architecture and directories.
We need to understand how airflow works before we can build the docker compose file that will be used
to run the airflow containers.
So I will see you in the next lecture to go over the airflow architecture.