Pulling a Docker image on an AWS EC2 instance from Docker Hub
To run a Docker container, we need to have a Docker image, which we can either build from a DockerFile
or can pull from any of the public or private Docker registries, such as Docker Hub, Quay, Google Container Registry, AWS Container Registry, and so on.
As we have already learned how to create a Docker image from a DockerFile
and push it to Docker Hub in Chapter 9, Working with Go and Docker, we will not build an image again in this recipe. Instead, we will be pulling the pre-built image from Docker Hub on an EC2 instance.
Note
See the Building your first Go Docker image recipe in Chapter 9, Working with Go and Docker.
How to do it…
- Login into Docker Hub using your credentials from the command line by executing the following command:
$ docker login --username arpitaggarwal --password XXXXX Login Succeeded
- Execute the
docker pull
command to pullarpitaggarwal/golang-image
from Docker Hub, as follows:
$ docker pull arpitaggarwal/golang...