$
docker images
REPOSITORY TAG IMAGE
ID CREATED VIRTUAL SIZE
flask latest 88d6464d1f42 5 days ago 354.6 MB
...
To push this image to your Docker Hub account, you need to tag this image with
your own Docker Hub repository with the
docker tag
command (see
Recipe 2.6
):
$ docker tag flask how2dock/flask
sebimac:flask sebgoa$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
flask latest 88d6464d1f42 5 days ago 354.6 MB
how2dock/flask latest 88d6464d1f42 5 days ago 354.6 MB
You now have your Flask image with the repository of
how2dock/flask
, which follows
the proper naming convention for repositories. You are ready to push the image.
Docker will attempt to push the various layers that make the image; if the layer is pre-
existing
on the Docker Hub, it will skip it. Once the push is finished, the
how2dock/
flask
image will be visible in your Docker Hub page, and anyone will be able to
docker pull how2dock/flask
(see
Figure 2-1
):
$ docker push how2dock/flask
The push refers to a repository [how2dock/flask] (len: 1)
Sending image list
Pushing repository how2dock/flask (1 tags)
511136ea3c5a:
Image already pushed, skipping
01bf15a18638: Image already pushed, skipping
...
dc4a9a43bb7f:
Image successfully pushed
e394b9fbe3fa: Image successfully pushed
3f7abcdc10d4: Image successfully pushed
88d6464d1f42: Image successfully pushed
Pushing tag for rev [88d6464d1f42] on
{https://cdn-registry-1.docker.io/v1/repositories/how2dock/flask/tags/latest}
56 | Chapter 2: Image Creation and Sharing
Figure 2-1. Docker Hub Flask image
Discussion
The
docker tag
command allows you to change the repository and tag of an image.
In this example,
you did not specify a tag, so Docker assigned it the
latest
tag. You
could choose to specify tags and push these to Docker Hub, maintaining several ver‐
sions of an image in the same repository.
This recipe introduced two new docker CLI commands:
docker tag
and
docker
push
. One more is worth noting, in terms of image management:
docker search
. It
allows you to search for images in Docker Hub. For example, if you are looking for an
image
that would give you
postgres
:
$ docker search postgres
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
postgres The PostgreSQL ... 402 [OK]
paintedfox/postgresql A docker image ... 50 [OK]
helmi03/docker-postgis PostGIS 2.1 in ... 20 [OK]
atlassianfan/jira Atlassian Jira ... 17 [OK]
orchardup/postgresql https://github ... 16 [OK]
abevoelker/ruby Ruby 2.1.2, Post ... 13 [OK]
slafs/sentry my approach for ... 12 [OK]
...
The command returns over 600 images. The first one is the official Postgres image
maintained by the Postgres team. The other ones are images created by users of
Docker Hub. Some of the images are
built and pushed automatically, and you will
learn about automated builds in
Recipe 2.12
.
Do'stlaringiz bilan baham: