Publishing an image to the registry
As mentioned in the previous recipe, Docker image registries act as hubs to store and share images. In this recipe, we'll see how to push the image to the registry using the docker image push
command. Later in this chapter, we'll cover how to set up the private registry.
Getting ready
Ensure that you have successfully logged in to hub.docker.com because, in this recipe, we will be pushing an image to hub.docker.com. Alternatively, you could use a private or third-party Docker image registry.
How to do it...
The following are two syntaxes for the command that is used to push a Docker image to a registry:
$ docker image push [OPTIONS] NAME[:TAG]$ docker push [OPTIONS] NAME[:TAG]
To push an image to a Docker registry, go through the following steps:
- Begin by tagging the image using the
docker image tag
command with the appropriate user or organization in the Docker hub, as shown in the following code:
$ docker image tag myapache2 cookbook/myapache2
Here, the image...