Twitter

miercuri, 2 decembrie 2015

Push/pull a Docker image to/from Docker Hub using Virtual Box on Windows

! INSTEAD OF anghelleonard USE YOUR NAME

In the previous post, I've created a Docker image for running OmniFaces Showcase WAR under WildFly 8.2.0 Final. If you followed the previous posts, then you should be able to start my-machine (just open Virtual Box locate the machine and hit start) and run docker images command:


Push to Docker Hub 
Further, let's share the anghelleonard/omnifaceswildfly image with other Docker users. For this, we can use Docker Hub. Currently, Docker Hub contains 100,000+ free apps, public and private registries, so is a pretty large repository with great visibility on Internet.

1. First, you need to create your account on Docker Hub. After you accomplish this simple step, you are ready to push images. For this, you need to create a repository:


2. Now, you should see the GUI for creating your repository. The important thing here is to select a namespace and to provide the repository name. In our case, the image is named anghelleonard/omnifaceswildfly. The anghelleonard part represent the user id (default namespace), while the  omnifaceswildfly represents the repository name. So, I can simply select the anghelleonard namespace, and type omnifaceswildfly name. For the moment I leave un-filled the rest of fields and click the Create button:


3. Further, you should see something like below:


4. At this point, we are ready to push the image on this repository. Get back to my-machine console and login to this repo. In order to login, you need to provide the user, email and password used to create your Docker Hub account:

Command: docker login


5. Finally, we can push the desired image in the repository. For this, just type the following command (notice that this will take a while!):

Command: docker push anghelleonard/omnifaceswildfly


6. After the process stops, you can check the available Tags in your repository; we didn't specify a tag at push time, so you will see the latest tag (do not forget to refresh page):


7. Finally, switch to Repo Info and fill the desired information:



Done! You successfully pushed and shared an image on Docker Hub.

Pull to Docker Hub 
Docker Hub allows us to share images, but it also allows us to pull images. For example, let's pull our image to see if everything works fine:

1. We can pull an image via the docker pull command. For example for anghelleonard/omnifaceswildfly image, we type the following command:

Command: docker pull anghelleonard/omnifaceswildfly


2. Well, instead of pulling the image from Docker Hub, we see a message of type "Image is up to date for anghelleonard/omnifaceswildfly". This message appears because we have this image "locally" on my-machine, and is up to date. In order to perform the pull, we need to delete the local image and try again. In order to delete a single image, you can use docker rmi image_name command, but we will delete all containers and images. For this we need two commands:

Command (remove all containers): docker rm $(docker ps -a -q)


Command (remove all images): docker rmi $(docker images -q)


3. Now, you can try to pull the anghelleonard/omnifaceswildfly image again - notice that this time the image is downloaded from Docker Hub:

Command: docker pull anghelleonard/omnifaceswildfly


Done! You have successfully pulled an image from Docker Hub.

A quick docker images command will reveal that images is on my-machine:


Finally, you can run the image and enjoy with OmniFaces Showcase application as you saw in "Create and run a Docker image from Dockerfile on Windows 7 via Command Prompt "

Note: In order to see all the options for docker-machine command try:

Command: docker-machine --help

Niciun comentariu:

Trimiteți un comentariu