Uploading container images to container registry

We now want to upload the Docker-based container images that we have created in the previous steps to a container registry.

Why:

  • We want to execute container images on the Azure cloud as facilitated by ACS
  • In order for us to run the containers on ACS, we need to push them
  • Either we push the container binaries manually, or have them uploaded and stored on some public or private container registry over the Internet.
  • So, we will first push our images from our local (DEV) VM to (our selected) Docker Hub, which is a public container registry available to be used for free for public containers
  • The next step will be to pull the images from Docker Hub to ACS, then install and execute them

First of all, create a Docker Hub account for free; my Docker Hub account, for example, is habibcs. Then, we create a repository in our account with the name eea-spa, which appears in Docker Hhub as seen in the following screenshot shown as follows in the docker hub:

A repository in a Docker Hub container registry

We now want to push our image to this repository. Run the docker images command on your CentOS VM to see the list of images installed on the machine (or call it a docker node). The names we gave to our frontend container and backend containers were mathappfe , and the backend container was mathwebapi respectively, which will appear as the output of the command beside other images:

List of images available on the machine

To push our frontend image successfully to Docker Hub, we need to execute the following command to log in to your Docker account via Docker CLI:

docker login

Execute the following command to tag the container image:

docker tag 8e4917865c26 habibcs/eea-spa

We tag our existing container image using its IMAGE_ID with the repository name we want to push to:

docker push habibcs/eea-spa

We push the image to our repository on Docker Hub:

docker container rm 46c07d651266

We now remove the container installed locally by using its CONTAINER_ID; 46c07d651266 in my case:

docker rmi -f 8e4917865c26

We now remove the image by using the Image_ ID.

To test whether our operations worked successfully, we execute the following command:

docker run --name eea-spa-container -t -d -p 8080:80 habibcs/eea-spa

This will download the image-- habibcs/eea-spa from Docker Hub, since it has been removed from our system, and then create a container instance of it with the name of eea-spa-container, and execute it by exposing internal port 80 to port 8080 on the host VM. After that, the final behavior will be exactly the same as what we have done before with the locally built Docker image.

We repeat the same steps to upload our backend microservice image once after creating the eea-be-mathwebapi repository on the Docker Hhub.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.107.210