One can easily build docker images through docker build command.
What I'm wondering is the t flag that you can give when building the image. For example:
$ docker build -t ouruser/sinatra:v2 .
According to documentation, the t flag is for tagging and naming purposes. Name is the part before ':', and tag is the part after it. So in our example, the name is ouruser/sinatra, and the tag is v2.
I thought this would be the image name and tag. But apparently, the name is actually some repository name? Why do I think it is? Well, because if you would after this list the images with command:
docker images
You would get a listing like this:
REPOSITORY TAG IMAGE ID CREATED SIZE
ouruser/sinatra latest 5db5f8471261 11 hours ago 446.7 M
Bang! Major shock! You thought you were creating an image with name, and instead, you specified some repository! Related to this, I have some questions:
Thank you for your help!
The repository name needs to be unique in that namespace, can be two to 255 characters, and can only contain lowercase letters, numbers, hyphens ( - ), and underscores ( _ ). Note: You can't rename a Docker Hub repository once it's created. The description can be up to 100 characters and used in the search result.
To give tag to a docker file during build command: docker build -t image_name:tag_name . otherwise it will give latest tag to you image automatically.
To specify a value for repository and tag of the image, we use the --tag or -t flag with the $ docker build command. The format of the value for this flag is <repository>:<tag> . If we leave the :<tag> part out, Docker will use the latest value for the <tag> part implicitly.
From the Docker Hub dashboard, click Create Repository. Fill out the repository details (be sure to set the Visibility drop-down to either public or private), then click Create. On the next page you will find details about your new repository, including the docker pull command for your images.
I believe the confusion here is the word "repository." In Docker, a repository is any group of builds of an image with the same name, and potentially multiple tags. A "registry" server, like hub.docker.com or your own private registry, holds multiple repositories, e.g. the redis repository on the public registry. That one repository has multiple tags for different versions of the build.
So with that background, to answer your questions:
docker push
docker save
you can save that image for a docker load
on another host.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With