How to push an image id to docker repo - docker

When I run the command docker ps I get a list of containers like this:
6f8d5585918f 56058f3d1997 "test" 23 hours ago Up 23 hours test1
18edba56bfeb 2482781314c7 "java -jar test2" 2 days ago Up 2 days 0.0.0.0:8206->8484/tcp test2
The second column is the image. I want to push the second image as test11 to our private repo. I don't have the files to build the image. How would I do this?

First you must tag the image ID. The you must login to your private Docker registry. (The correct name is registry and not repository. A Docker registry holds repositories). Then you push the image.
Substitute privateregistry with the hostname of the Registry.
docker tag 2482781314c7 privateregistry/test11
docker login privateregistry
docker push privateregistry/test11

Related

Pulling from repository

I just created an image :
docker build firstimage .
and tagged it as sohrabp72/firstimage and then pushed it into my repo on the Docker hub:
docker tag firstimage sohrabp72/firstimage
Then I removed the tagged image and the original image from my local machine:
docker rmi sohrabp72/firstimage
docker rmi firstimage
Now when I want to pull the image from the Docker hub repository, my local Docker does not pull it:
C:\Users\Sohrab> docker pull sohrabp72/firstimage
Using default tag: latest
latest: Pulling from sohrabp72/firstimage
cbdbe7a5bc2a: Already exists
9287919c3a0f: Already exists
43a47bbd54c9: Already exists
3c1bcea295c4: Already exists
53e2ab46e733: Already exists
3b08dc288a15: Already exists
e01ad7774a4c: Already exists
Digest: sha256:f16f1cfd9e777898511259e7ff512947c27b7e7bb4f4333dd27bd809bdc77995
Status: Downloaded newer image for sohrabp72/firstimage:latest
docker.io/sohrabp72/firstimage:latest
PS C:\Users\Sohrab>
docker logs show some lines and say already exist. and when I look at images on my local docker, that image is there:
C:\Users\Sohrab> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
getting-started latest bfc5750a86e5 11 hours ago 231MB
sohrabp72/firstimage latest 4e197282638a 22 hours ago 179MB
node 12-alpine d8b74300d554 7 days ago 89.6MB
docker/getting-started latest 1f32459ef038 3 months ago 26.8MB
Is there something like a cache for images we've pushed to Docker hub?
When docker prepares an image, it does step by step and each step creates an intermediate step with an ID. Docker by default removes the intermediate image and the last step provides a final image with an ID.
When you ran build command it actually created a final image with an ID and tagged the final image ID with your name 'firstimage'
When you tag second name, it added additional tag 'sohrabp72/firstimage'
When you ran docker rmi command on both tags, it removed tags only while image created still is there.
You can run
docker images -a
which will list image with <<"none">> in repository and name but final image created will be there with ID
you can
docker image prune -a
to clear all image and try docker pull command

Docker push local image under specified tag name

I need to push Docker image from my local machine to my https://hub.docker.com repository under the specified tag name.
Locally I have the following image:
REPOSITORY TAG IMAGE ID CREATED SIZE
repo1/private image1 29234rs8dsf 5 months ago 1.07GB
Hot to push this image under the specified tag(not latest, for example, testtag1) under my https://hub.docker.com repository inttest/myimage ?
If i understood the question correctly, you can do it with following 3 steps -
TAG your local image to dockerhub repo image -
$ docker tag repo1/private:image1 inttest/myimage:testtag1
Login to your dockerhub account using docker login
Push your dockerhub repo tagged image -
$ docker push inttest/myimage:testtag1

can't push or pull to a docker repo `Repository not found`

I am new to docker. created a public repo under my account
link to repo
I am able to pull other public repos like redis and debian:
docker ps ✱
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
40416ad4c715 debian:latest "/bin/sh -c 'while t 6 minutes ago Up 6 minutes dal_server
but when trying to pull from my repo i get an error:
docker pull opmaster/basic_server ✱
Pulling repository opmaster/basic_server
FATA[0009] Repository not found
docker push opmaster/basic_server ✱
The push refers to a repository [opmaster/basic_server] (len: 0)
FATA[0000] Repository does not exist: opmaster/basic_server
>> docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
debian latest 41b730702607 10 days ago 125.1 MB
hello-world latest 91c95931e552 3 weeks ago 910 B
>> docker tag 41b730702607 opmaster/basic_server:devel
>> docker push opmaster/basic_server
docker push can get be little long from my short experience, so i stopped it with ctrl-c, did boot2docker restart and started again with the docker push opmaster/basic_server
if someone knows a better way, i'm open to suggestions.
You don't appear to have a valid image on dockerhub. How did you create the image that is there? I see if, but there isn't anything in it.
Your images are created by pushing an image that you have locally, or with a Dockerfile (you can buuild an image). There is a good write up on how to push an image here:
https://docs.docker.com/userguide/dockerrepos/
Once you get a valid image pushed, pulling it will be possible. I have found pushing images (like the one you have listed in your docker ps) is easier to do if you tag it first. However, the easiest way to make images is to create a project for it on github, have a Dockerfile in that project, then auto build it (github checkin triggers a build on dockerhub).

Docker public registry push fails: Repository does not exist

I'm trying to push my docker image up into the public docker registry:
$ docker login
Username (binarybana):
WARNING: login credentials saved in /home/jknight/.dockercfg.
Login Succeeded
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
binarybana/dev-fedora latest 10c7881fbaca 24 hours ago 1.148 GB
binarybana/fedoradev latest 10c7881fbaca 24 hours ago 1.148 GB
binarybana/fedora-dev latest 10c7881fbaca 24 hours ago 1.148 GB
<none> <none> b44397dc4c99 24 hours ago 1.148 GB
<none> <none> a98c27ba4738 24 hours ago 1.141 GB
<none> <none> 775c74a34add 24 hours ago 1.141 GB
<none> <none> 2be2491d2354 24 hours ago 1.141 GB
docker.io/fedora 21 93be8052dfb8 7 days ago 241.3 MB
$ docker push binarybana/dev-fedora
Do you really want to push to public registry? [Y/n]: Y
The push refers to a repository [docker.io/binarybana/dev-fedora] (len: 0)
FATA[0001] Repository does not exist: docker.io/binarybana/dev-fedora
$ docker push binarybana/fedora-dev
Do you really want to push to public registry? [Y/n]: Y
The push refers to a repository [docker.io/binarybana/fedora-dev] (len: 0)
FATA[0002] Repository does not exist: docker.io/binarybana/fedora-dev
Yet, I've already created the repository (viewable here). And I've also tried to push to repository names that I haven't already created (the first try in the example above).
I think the (len: 0) has something to do with it, but I can't google it. Also I originally created the image from a dockerfile as:
docker build -t binarybana/fedora-dev .
Thanks.
Always build your image with "username" and "tag"
docker build -t <username>/dev-fedora:latest .
After building push the image
docker push <username>/dev-fedora:latest
if you are using docker.io ( dockerhub repo ), you need to tag it including the name docker.io in it.
docker tag ${image_id} docker.io/${login_name}/${image_name}
and then
docker push docker.io/${login_name}/${image_name}
is OK.
I also encountered this error Repository does not exist: gcr.io/my-project-id/my-container when attempting to push an image to Google Container Registry.
My confusion came from a misunderstanding of Docker's definition of "repository".
A repository is a set of Docker images. A repository can be shared by pushing it to a registry server. The different images in the repository can be labeled using tags.
When Docker says that a repository does not exist, it means that there is no image that it can find locally that is tagged with that registry.host/user-name/image-name combination.
Note: The Docker Hub registry is the default, so that part can be omitted if you are pushing there.
Steps to fix this issue:
Double check what images you have available locally.
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
gcr.io/my-proj/my-typo v1 40c2ae2dedb8 2 days ago 427.8 MB
If there is a typo, you can run the docker tag command to fix it.
$ docker tag gcr.io/my-proj/my-typo:v1 gcr.io/my-proj/my-cntr:v1
Now, you should be able to push the image using the complete name, including the tag.
$ docker push gcr.io/my-proj/my-cntr:v1
Note: Use gcloud docker -- push instead of docker push if you are pushing to the Google Container Registry.
If you are using Amazon AWS, before you can push your Docker images to Amazon ECR, you need to create a repository to store them in. You can create Amazon ECR repositories with the AWS Management Console, or with the AWS CLI and AWS SDKs.
To create a repository
1.) Open the Amazon ECS console at https://console.aws.amazon.com/ecs/.
2.) From the navigation bar, choose the region to create your repository in.
3.) On the Repositories page, choose Create repository.
4.) For Repository name, enter a unique name for your repository and choose Next step.
5.) Now you should be able to push to your AWS repo!
You need to use the complete image name. When you don't specify the tag while building, it's latest, so you should say
docker push binarybana/fedora-dev:latest
Adding to Santosh Gandhe's answer, if you want to push to specific repository rather than under your login name
docker tag ${image_name} docker.io/${login_name}/${remote_repo_name}:${image_name}
and then
docker push docker.io/${login_name}/${remote_repo_name}:${image_name}
Also, don't forget to do docker login first.

What's the meaning of docker hub's url design?

https://registry.hub.docker.com/_/ubuntu/
There is a _ in the url before the product name.
What is it for?
If you have a account on dockerhub called foobar:
# pull from your account (foobar)
docker pull foobar/ubuntu:latest
Otherwise, if you omit the username:
# pull from the official account (library)
docker pull ubuntu:latest
# almost the same as
docker pull library/ubuntu:latest
The underscore(_) is a special namespace used to publish the official repositories.
https://registry.hub.docker.com/_/ubuntu/ is almost the same as https://registry.hub.docker.com/u/library/ubuntu/
The only difference is that you will get different image-names with identical image-id:
$ docker pull ubuntu:latest
$ docker pull library/ubuntu:latest
$ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
library/ubuntu latest 86ce37374f40 7 days ago 192.7 MB
ubuntu latest 86ce37374f40 7 days ago 192.7 MB

Resources