Pushing images to Docker Hub
Here, we will create a Docker image on the local machine and push this image to Docker Hub. You need to perform the following steps in this section:
- Create a Docker image on the local machine by doing one of the following:
- Using the
docker commit
subcommand - Using the
docker commit
subcommand withDockerfile
- Pushing this created image to Docker Hub
- Deleting the image from Docker Hub
We will use the ubuntu
base image, run the container, add a new directory and a new file, and then create a new image. In Chapter 3, Building Images, we saw how to create a Docker image using Dockerfile
. You may refer to that chapter to check for details of the Dockerfile
syntax.
We will run the container with the containerforhub
name from the base ubuntu
image, as shown in the following Terminal code:
$ sudo docker run -i --name="containerforhub" -t ubuntu /bin/bash Unable to find image 'ubuntu:latest' locally latest: Pulling from library/ubuntu 952132ac251a: Pull complete Digest:...