0% found this document useful (0 votes)
23 views6 pages

My Documents

Step 1. Create a Docker Hub account to host and share Docker images. Step 2. Build a demo Python application image locally. Step 3. Tag the local image with the Docker Hub username to prepare it for pushing. Step 4. Push the tagged image to Docker Hub to share it. Step 5. Others can now pull the shared image from Docker Hub to run locally.

Uploaded by

Shivam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views6 pages

My Documents

Step 1. Create a Docker Hub account to host and share Docker images. Step 2. Build a demo Python application image locally. Step 3. Tag the local image with the Docker Hub username to prepare it for pushing. Step 4. Push the tagged image to Docker Hub to share it. Step 5. Others can now pull the shared image from Docker Hub to run locally.

Uploaded by

Shivam
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

EXPERIMENT NO 6

Aim :To perform Docker commands with push and pull commands.

Theory:
To Build your own Docker Image
1. Write a docker file
#mkdir mydockerbuild (create a directory named mydockerbuild)#cd mydockerbuild (go to
directory created above)#vi Dockerfile (create a new docker file using vi editor)

(copy below mentioned contents into your Dockerfile)

FROM docker/whalesay:latest
RUN apt-get -y update && apt-get install -y fortunes
CMD /usr/games/fortune -a | cowsay

2. Build docker image


#docker build -t docker-whale .

If you see ‘no permission’ error, try to prefix above command with ‘sudo’ as shown in above
snapshot.

3. Now if you can see your latest build using ‘docker images’ command
#docker images

4. Run your new docker-whale


build #docker run docker-whale

If you are programmer or in some way related to coding or software world, I assume that you
must be aware of GitHub. Similarly, there exists DockerHub.

What is DockerHub?

People all over the world create Docker images. You can find these images by browsing the
Docker Hub. In this next section, you’ll search for and find the image you’ll use in the rest of
this getting started.
What is Docker Store?

The Docker Store contains images from individuals like you and official images from
organisations like RedHat, IBM, Google, Microsoft, and a whole lot more. Each image
repository contains information about an image.

Create a Docker Hub account and repository


1. Sign up for a docker hub account: In your web browser, go to the Docker Hub
signup page.

2. This account is also valid for docker store.

3. Verify your email address and add a new repository:

4. 4. Learn to ‘tag’ and ‘push’ image to your docker hub account.

We will use our docker-whale image to push to docker hub account which you created above.

4.1 Run ‘docker images’ command to list all images

Third column of above output shows you docker Image ID

We will use this Image ID to tag our docker-whale image

4.2 Tag the ‘docker-whale’ image using the ‘docker tag’ command and the image
ID. #docker tag <image-id of docker-whale> <your dockerhub username>/docker-
whale:latest

Now if your use ‘docker images’ command to list images, you shall see your dockerhub
username against docker-whale image as shown in above snapshot.

5. Push your tagged image to Docker Hub, using the ‘docker push’ command

6. Go back to the Docker Hub website to see the newly-pushed image.

7. Pull your new image from docker hub

7.1 Use ‘docker images’ to list all your local images

7.2 Let’s remove all versions of docker-whale image on our local system
#docker rmi -f <Image ID of docker-whale>

Use ‘docker images’ command to confirm if all instances of ‘docker-whale’ has been
removed.

7.3 Now let’s run ‘docker-whale’ and see what happens.

When you use ‘docker run’ it automatically downloads (pulls) images that don’t yet
exist locally, creates a container, and starts it. Use the following command to pull and
run the ‘docker-whale’ image, substituting your Docker Hub username.

Output:
Step 1. Create a docker Hub account
Step2: Build a demo application my-python-app by running the following commands in
command prompt
Till now we have create the my-python-app file
See if the file is working in the browser using port number

Step3: See all the images present in the docker. Here you will see that my-python-app is also
present.

Step4: Login to the docker hub account

Step5: To push the image with your repository name

Step6: Check the images present, this should include the image name with repository

Step7: Push the image into docker hub account


You will see the application generated with the repository name in the docker container

See if build pack demo is listed in docker hub

Step8: Check that the images with the repository is now present in the list

Step9: Pull the image


Check it in the browser using the port number assigned.

Conclusion:
Built docker image with the help of python and then learned about the usage of docker image
push to share our images to the Docker Hub registry and also how to pull an image.

You might also like