Upload Images To Docker Hub
In this lecture you will learn how to upload your first image to Docker-Hub.
Docker-Hub is an image repository, very much like Git for Files. It will store images and tags of your images in a repository.
Docker-Hub Account
For this to work you need an actual Docker Account. If you donāt have one, you can either make one now or skip this lecture.
Create an Image and upload it to Docker-Hub
Use this Dockerfile:
FROM alpine
RUN apk update && apk add curl
ENTRYPOINT [ "curl" ]
Then build the image:
docker build -t mycurl .
- This will build an image
- It will tag the image as
mycurl
docker image ls
- List the images, there should be a
mycurl
image
docker run --rm mycurl www.google.com
- Should output the HTML from the google website
docker login
- Login to Docker-Hub
- If you donāt have a user-name then create one first
- Remember your username! Letās assume it is āmyUser123ā
docker tag mycurl myUser123/mycurl:latest
- Tag your image with āusername/repository:tagā -> āmyUser123/mycurl:latestā
docker image ls
- Lists also the new image as well, with the same container ID
docker push myUser123/mycurl:latest
- Pushes the image to docker hub
docker rmi mycurl
- Remove the āmycurlā image
docker rmi myUser123/mycurl:latest
- Remove the myUser123/mycurl:latgest image as well
docker run --rm myUser123/mycurl:latest www.google.com
- It will download the image again from docker hub from your public repository
docker rmi myUser123/mycurl:latest
- cleanup
Last updated on