Host your own docker registry | Local Docker Registry | Docker Registry using Docker Compose

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] [Music] hello people this is Selkirk's and in this video we'll be learning that how you can host your own docker registry and then you can push your docker images there and then you can pull those docker images so one of the important term is talk a registry and we will understand that what a docker registry is and then we'll create or you or deploy our own docker registry so for understanding a docker registry we need to understand this concept so let's say you're having your own machine which means that you are using your laptop or your desktop so I have designated this as node one now when you have docker installed on the system then you fire a command docker pull image and version so this is the basic command that you use when you are working with docker when you fire this command then this docker client will do something what it will do it will go to docker hub so docker hub is a cloud-based service which has been deployed by the docker people where other people can host their images which means that you can create your own image and then you can push the image those images to this particular docker hub so when I fire this command docker pull then what happens it connects to this particular docker hub and it pulls the image which has been given here this is a scenario where we are using cloud-based oper hub and it is being managed by docker people so suppose you are working on your project you have your own docker images and you want to host those docker images locally for your office work for your company or for your team work then you need to host your own docker registry so in that case what we are going to do we will be having an ode to that will be a separate machine and we'll install this docker registry there so that when you fire this come on docker pull image name and version so it will call it will connect to this particular docker registry and pull the image from there so this is the overall thing that we are going to do that is we are going to host our own docker registry so docker registry is a place where people can post their image and then other people can download it so in your scenario or in a scenario a particular company they create the images of their product and they will host those images in their own docker registry which is which has been deployed in right there of his network the prerequisite if for following this video is that the local machine should have docker installed which means this node one should have docker installed so if Dockett is installed then docker client will be present there and no - should have docker installed and docker compose installed so we'll start the registry services using docker compose so docker compose is an important application that should be installed inside this node - now the prerequisite if should be fulfilled then only we can follow this particular or we can create your own docker registry we'll go to our linux box here and I am going to node 1 so this is my node 1 and I'm inside this particular docker registry folder the docker registry app and it is empty so this is node 1 where docker is present so I'll type the command docker and you can see the docker client is working now I'll open a new tab here so you can see a new tab is present here on the right hand side and I connect to my other machine so I connect that machine using SSH so I'll say SSH and then self dot so self thoughts is the name of the user there and then the IP address so it is 10.40 2.0.1 so this IP address will differ based on your machine so you need to know the IP address of your system where you will be creating or where you will be hosting your own docker registry so this is the IP address and if I do it enter you can see I went inside our bun to machine and it has successfully entered here so if I do LS so it is present here if I do if config which will show the IP address so you can see this is 10.40 2.0.1 so this is the IP address now here there is a folder workspace present I will go inside this workspace and I'll create a new folder that is talker registry so this folder can be anything so docker registry now we'll be using docker compose file to create thus to host the services so I'll create a docker compose file so it will be docker compose dot e ml so the extension should be ml and I'll be using version 3 of docker compose so I'll say 3 dash and then I'll say the version that we are going to use is what is 3 so this is the version so in docker compose we need to define our services so we'll write services and the first service will be what it will be talking registry so this is the name of the service so you can give anything ABC PQR only docker registry my own docker is to creating a service we need to have an image so we'll go to our Chrome browser and we'll search for docker registry so we'll say docker registry and this will take us to the distrito ker hub this is a docker registry image which has been given by docker official images or the docker people only so this says that this is the registry image and these are the different tags that are present and you can also view the docker file etcetera and different configuration so this is the registry and it is having different version so I'll be using version 2 so we'll say the image that we are going to use for creating this particular services for registry and the version will be what the version will be - so I'll save this and then if I'm going to create a container so the container name will be what the container name will be talker registry so this can be anything so the container name can be anything ABC P Q or whatever you want to provide but the image that we'll be using is registry colon 2 which means the second person to of registry image now we need to connect to the port or we need to put forward the host machine port and the inside port of the docker so if I go inside this docker file of registry image so you can see I'll go inside any docker file so it will show the configuration and you can see the 5000 port has been exposed and this volume Valley registry is there so the port exposed inside the docker container is what 5000 and I expose the same port of the host machine so I will say 5000 and then 5000 so when I'm writing this particular port 5000 colon 5000 what it means that if I'm hosting my docker container or docker registry inside this then it will create a container here and inside the current the 5,000 port will be exposed but from outside if someone wants to connect to that docker registry then this particular node 2 machine will have 5000 port connected to the inside 5,000 port of the docker container so you need to have these particular concepts then only you can create your own docker compose file so once the port has been finalized that I use 5000 then what I need to do I need to just say that restart always so that if this particular containers gets crashed then also it will restart itself so always so I think restart and there are some blank spaces that's why it is giving error so restart always and then we need to say what we need to say the volume which we want to use so we will create a dot volume folder which means that in the particular folder will where we will be running docker compose will create a volume folder that will be connected toward that will be connected to where Lib and then a registry so this is the particular folder which will be present inside the container and we are mounting that to the volume folder that will be creating so why we are doing this because when we will push our images to this particular docker registry then it should persist which means that even though the container crashes then also we can get the images later on so that if the container crashes then we'll restart the docker registry and then also we can get our images it is not that if the container crashes then all the images are gone so this is the first service that we are defining the second service is what we need to use a GUI which means we need to use a UI from where we can see the contents which is present inside the docker registry which are the images present which is the user present which user has hosted which images so we'll be using another docker container and that will be what docker registry front-end will just search it and we'll go to this particular user and here we will go to this docker registry front end so we'll be using this particular image to view our images that are present inside the docker registry so you can use any other docker image to view to make your front-end work but I'll be using this so I will copy this particular one registry front-end and these are the different tags which are present so we will be using what we'll be using words and - the latest one so if this video if the video you are seeing after some time then there may be other tag if you want to use that then that is also good so I'll create another service that is talker registry and then UI so this is the name of the service and inside the service I'll be using image will be what image will be this one that we have copied from there and we'll be using person too so I copy this and then what we need to do we need to provide a container name so that we'll get a beautiful container name in our docker PS command so it is container name and the name of the container will be what docker registry UI so this is the docker container name it can be anything whatever you like and then we need to do port forwarding so it will be ports and here we want to use X 0 8 0 port of the host machine which will be bind it to the port 80 of the docker container so I'll come here and then what we need to do we need to give some environment variable so I will show you what these environment variables are so I will go to this particular on D kaeleen docker registry front end and if I go here overview then you can see these are the different configuration features which will be used and this is the command to start the docker so there are some environment variables so these are the environment variables so I will copy this particular one one first one is en will talk a registry so I will take this I will do a control C I'll come here and I'll paste it here same way I'll take the second one and docker this 3 port focus I'll do control C and then control V so what does this environment variable mean this me that when this docker registry UI will be instantiated then it should know that - which docker registry back-end it should get connected so that it can you can view the images that are present so environment docker registry host is the name of the docker container that you need to provide here so the name of the container is what docker registry so we'll say docker and then a registry and then what is the port so on which port this one is working so you need to provide that so it is port 5000 so we are done with this that means we have defined to services in our docker compose 1 a stoker registry and one is talked of registry UI so we will save this file and then we'll create a directory here the directory name will be Ward mkdir volume so this volume directory is mounted inside the docker compose file for the docker registry container so this whole folder has been created and now we will start our services so we'll say docker compose - f that is file name so this is the file name and then we will do up so this will start the docker services which we have defined inside the docker compose file now it will start for pulling the images first because it was not present on my local system of this particular node that is note 2 so it will download those images and then it will create the container out of it so this may take some time of depending on the internet speed so when it comes when the whole image is fully downloaded the container will be created so both the images has been downloaded you can see here that docker history front end was downloaded and then that registry was also downloaded so if I come here so the docker registry front end was downloaded and then the registry image was also downloaded from docker hub and the service has been started so these two services are running on my node 2 that is on IP 10.40 2.0.1 now if I go to my browser here and if I type 10.40 2.0.1 and then we need to provide the port that we have or so you remember that we have written the 8:08 report of dhaka front end so you can see here that welcome to talk and registry and we can browse the repeal registry of this particular docker registry so there are no images currently present and this is the GUI that is the front end so this front end is getting connected to the docker registry back-end so there's no image present because we have not post any that's why it is empty now we'll come to our terminal here and I'll go to my node one so this is node 1 so we are having two tabs here registry app which is node 1 which is my local machine where we'll create the image or we will create a new image and we'll push that image through docker registry so I'll do LS here so this folder is empty now in my node 1 that is here if I go to the image so this is node 1 and this is the docker registry so we have started the dog Arista here and then here we need to configure something so for the first configuration is what we need to update the host file so I'll go as the root user so I enter the password and ok it will take time so authentication feel yes so I'll do it correctly so this time we are now into root user so you can do it through rude user or your user if it is having sudo privileges that depends on your machine so I'll open vim et Cie and then host file so your host file can contain some other entries but you need to add a new entry and that is what you need to provide the IP address of the docker registry node so that is 10.40 2.0.1 so this IP will change based on your machine it is not fixed but this thing is fixed that you need to provide self dot dot local calm so you need to provide a hostname to your particular docker registry and then from your this machine that is node 1 you can ping using self dot dot local com so even though the IP changes then your hostname will be same so I'll save it and I will do ping and then self turds local.com so you can see here time for for 0.53 milliseconds so my node 1 that is this node is getting connected to this node 2 so this node 1 is able to ping to node 2 which means the has been established now I do a control see here the first change was this the second change is what the docker registry that is running here which means this one so if I come here okay so the docker registry that is running here is not secure which means it is not authenticated so you need to update some configuration in your daughter client of node one so that you can connect to this docker registry so I will come here and you need to open what a TC and then docker and then Damon dot JSON so this is the file that you need to create if it is not present if it is present then you need to update it with a particular this one so I'll say in secure registry registry so you need to provide the registries that are insecure so that the dr. Kline can connect to them so it is what that one is it is what insecure registry so the spelling is correct insecure registries okay and I need to provide a colon here so that everything is fine because it is GSM so insecure registries and I will say self turts dot local.com because the host name which I have provided in my rim slash EDC slash host is self dot start local comm so it is the host name that you will provide so you will update that host name in this particular file so what I will do I stopped the talker service so it will be service docker stop so this command will change depending on your machine for Windows it will be other for other ubuntu it can be other thing so you need to stop your docker service and then you need to start the docker service so this is the basic thing that you need to update your diamond adjacent file which will be present inside a TC docker demanda Jason if it is not there then you need to create it you need to provide what you need to provide this particular line that is inside your registries and the host name that you have provided in your host file of your particular system so this was already and now what we need to do will exit from here so that we have been to the self-taught user so once this has been done and the docker service has been restarted then what you need to do you need to create a image so I look download I image so if i say here docker images then you can see no image is present so i talk a do docker pull and then alpine so this command will do what this will go to the default docker hub and download the Alpine image from there it is not going to our registry so it is default by default getting connected to the docker hub now once this image has been downloaded so I see docker images and you can see Alpine image is present then what you need to do you need to tag this image with your docker registry hostname so what we'll do we'll tag this so we'll say docker and then tag so we are creating a new image or we are tagging this image with a new tag and that will be what the first thing is what we need to provide the base image that is alpine and it is what latest so alpine and the tag is latest so we are using Alpine latest and then what we need to do we need to provide the hostname so we will say self turts dot local.com and the port of the registry and then what we need to do we need to provide the username which will be created mint v which user is creating this image so i'll say self dots and then image name so image name will be what I'll say alpine surf dots so this is just a demo that I am using the Alpine image which which has been provided by the docker hub and I'm tagging it as a different name and then I'll upload that to my talk her own docker registry so I'll say v1 ok let's say it is v1 Alpine self that's v1 so I'll tag it ok so now if I say docker images so what I will find I will find two images alpine and self dots local.com 5000 so when you are tagging you need to use this command docker tag and pine lettuce which is the base image and then the tag so tag will contain the hostname the port and then a username and this so this username the name of the image everything is configurable based on what are the settings that you have you have provided so I have provided the hostname in my hosts file a shelter calm my docker registry is running on port 5000 so I've given 5,000 I want to create a user with the name shelters it can be ABC it can be John or anything and then the name of the images also what you want to provide so this has been created and then what we need to do we need to say docker push and then the image that is self totes local.com 5000 the name and the version so the version is what here tag so the tag is v1 so I'm writing even so let's see everything works fine and you can see here that push refers to this ok so it is saying HTTP client so I think mmm very sheltered start local.com I'll again go to this route and then I'll type this EDC and then docker and then Jason so it is perfect that is we have provided in secured registries ok one thing is missing I need to provide the port also ok so that was missing so port is there again I need to stop the talker service so I'll say service docker stop and then I need to restart it so I will say service talker start so this will you start the service I can exit so that I can come to myself towards user and I will fire the command what docker push and this time it is preparing and it is pushing the image there so the image has been successfully posed and if I go to my browser and if I reload it this time you can see that self that's user is there so home browse repositories self-taught user is there and Alpine self text image is there so we have successfully hosted our docker registry there means image there so I'll come to my node to I'll do a control C so that I can stop my services because it was running in foreground and to start that in backend I'll use the minus T command for Damon so this will start the container means start that docker registry UI and docker registry here ok so everything is fine and if I say docker PS so these are the two docker container that has been created now my docker registry is running in in background and everything is fine so I'll come again here and I'll do what docker images okay I'll delete this particular image so I'll say docker RMI means remove image and the name of the image so this image and the version 1 so I will remove this image and I will say docker images so that you can see that only one image is present now I'll download this image from my own docker registry so if I come here through docker registry if I do a reload then you can see this particular v1 is present and if I come here so this is sheltered alpine and it is saying docker pool so I will copy this command i come here i will do insert and you can see error response no such hosts ok it is saying no search hose because i need to provide the actual hostname so it will be self turts dot local.com so now if I do docker images you can see the image has come so this was all about how to host your own docker registry how to tag the image and then you need to upload that or push that image to your own docker registry so this way your company or your team can host their own local private set of docker registry they can push the images there and they can pull the images and work on it so you need so there's no need for going to docker hub every time because your product is there and you don't need to host your own source code to cloud services so you need to create your own local docker registry and push the code there so this was all about this video hope you liked this video hope you like my channel please subscribe to my channel and please share these videos with other people thank you
Info
Channel: SelfTuts
Views: 38,089
Rating: 4.8293028 out of 5
Keywords: docker, docker compose, docker registry, host own docker registry, deploy your own docker registry, local docker registry, how to host own docker registry, docker registry using docker compose
Id: 8gEs_zefNYA
Channel Id: undefined
Length: 24min 4sec (1444 seconds)
Published: Thu May 09 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.