Is it possible to push images to the Docker registry using podman?
I am running podman with the podman-docker (that claims to emulate the Docker CLI) package on fedora and I managed to successfully run docker login with my hub.docker.com credentials, but when I try to push an image it fails to connect.
It was enough to specify the address of the docker registry
docker push imageID docker://docker.io/username/ImageName:tag
For me, I had to be more explicit than the answer above:
podman system prune -a
podman login -u myuser -p mypassword docker.io/myuser/myimage
podman build -t localhost/myimage .
$ podman images
REPOSITORY TAG IMAGE ID CREATED SIZE
localhost/myimage latest 1546573dd25d About a minute ago 716 MB
docker.io/library/docker 19.03.12-dind 66dc2d45749a 20 months ago 227 MB
podman push 1546573dd25d docker://docker.io/myuser/myimage:1.0.0
I did add dockerhub to my registries.conf. Not sure if its stricly required.
$ cat /etc/containers/registries.conf
[registries.search]
registries = ['docker.io', 'quay.io']
But I can just push as you would expect with docker.
podman build -t myuser/myimage .
podman login -u myuser
podman push myuser/myimage
podman version is 3.4.2
Related
I have got the Verdaccio running with docker on my system using:
docker pull verdaccio/verdaccio
docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
I can then see my Verdaccio at localhost:4873.
I add a user:
npm adduser --registry http://localhost:4873/
I go to a simple package repo and publish it:
npm publish --registry http://localhost:4873/
I then go to the browser and see my package is in the list on localhost
I then rename my docker container:
docker rename 4d2b---3692 my-container
On docker hub I have a repo called myuser/my-container
I then commit my container
docker commit 93ba9d----e myuser/my-container
Then I push it to Docker Hub (I did log in already)
docker push myuser/my-container
I see that it is updated on my Docker Hub.
I remove everything related to Docker on my computer
docker rmi --force 93ba9d----e
I then see nothing when I run these commands
docker ps -a
docker images
Then I try and pull my container
docker pull myuser/my-container
I then run my container
docker run -it --rm --name verdaccio -p 4873:4873 myuser/my-container
I can then see the Verdaccio page on localhost:4873, however I can not see the published package.
Please let me know what I am missing, thanks.
When build images in dind (docker in docker), the image is only accessible in dind.
$ docker run -d --name dind --privileged --net=host -v `pwd`:/app -w /app docker:stable-dind
fe66d6e7e5effcf15e439a332a2368fddab810e9bc8ac3445392c8e56b0aa38a
$ docker exec dind ls
Dockerfile
$ docker exec dind docker build -t demo .
Sending build context to Docker daemon 521.7kB
Step 1/24 : FROM alpine
...
$ docker exec dind docker images|grep demo
REPOSITORY TAG IMAGE ID CREATED SIZE
demo latest a9dd4e725029 7 seconds ago 88.3MB
$ docker images |grep demo
<no result>
I can push the image to public or private docker registry server in dind, because they have IP or dns name to access. But how can I push the new image back to localhost (the host running dind)
Second, if I want to pull image from localhost in Dind, how to do that?
I can answer my first question now.
$ docker exec dind docker save demo |docker load
2f7d711abbe9: Loading layer [==================================================>] 11.44MB/11.44MB
...
Loaded image: demo:latest
$ docker images |grep demo
demo latest a9dd4e725029 8 minutes ago 88.3MB
Same size :-)
But still not sure how to pull image from localhost in Dind, any ideas?
Below are steps to reproduce the issue.
docker --version
Docker version 17.09.1-ce, build 19e2cf6
docker images | grep centos
centos latest 3fa822599e10 3 weeks ago 204MB
docker tag centos:latest 127.0.0.1:5000/centos
docker push 127.0.0.1:5000/centos
The push refers to a repository [127.0.0.1:5000/centos]
d1be66a59bc5: Pushed
latest: digest:
sha256:3a32a170c945ffe18334b3f514fcb66f9c14001b2266c9ed8504c72db0acde11 size: 529
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
046a5d68c8b2 registry:2 "/entrypoint.sh /e..." About an hour ago Up About an hour 0.0.0.0:5000->5000/tcp festive_wozniak
curl -X GET http://localhost:5000/v2/_catalog
{"repositories":["centos"]} -----We can list 'centos' repo after pushing.
docker stop 046a5d68c8b2
046a5d68c8b2
docker run -p 5000:5000 -d registry:2
bad6ec7aad590f91aaf1721703ce6468e8254d159e56a5b5f018e5e3c25cf7e0
curl -X GET http://localhost:5000/v2/_catalog
{"repositories":[]} ---- after restarting registry, we cannot see 'centos' info
Each docker run creates a new container.
To restart a container you can either run docker start 046a5d68c8b2 (following your example) or use the --restart=always option to docker run.
See:
https://docs.docker.com/engine/reference/commandline/run/#restart-policies-restart
After I upgrade my docker from 1.8.2-el7 to version 1.12.6, its failing to pull my private images from docker hub.
I could able to perform the list image command
sudo docker -H tcp://test-app01.local:2376 images
REPOSITORY TAG IMAGE ID CREATED SIZE
account/image1 tag1 a4c286f0ec9e 10 hours ago 864.7 MB
ubuntu latest d355ed3537e9 8 days ago 119.2 MB
account/image1 tag2 4abd8c3ed720 3 months ago 878.8 MB
But it's unable to pull latest image from repo with successful login.
sudo docker -H tcp://test-app01.local:2376 login -u username -p password
Login Succeeded
sudo docker -H tcp://test-app01.local:2376 pull account/image1:tag1
Using default tag: tag1
Pulling repository docker.io/account/image1
Error: image account/image1:latest not found
Can somebody please assist to fix this issue.
As you can see in the image command, you have only tag1 and tag2 image tags.
If you don't specify any, docker will look for latest which you don't have. So pull as this for tag1:
sudo docker -H tcp://test-app01.local:2376 pull account/image1:tag1
Or this for tag2:
sudo docker -H tcp://test-app01.local:2376 pull account/image1:tag2
Let's say one of the official docker base images ubuntu:latest and I have a dockerhub account myaccount. How to clone ubuntu:latest to myaccount's repository? The work flow can then be introduced as follows,
$ docker pull myaccount/ubuntu:latest
$ docker run -it myaccount/ubuntu:latest /bin/bash
# root#mycontainer: apt-get install onepackage
# root#mycontainer: exit
$ docker commit mycontainer myaccount/ubuntu:latest-new
$ docker push myaccount/ubuntu:latest-new
I need push just the delta latest-new minus latest.
Use docker tag ubuntu:latest myaccount/ubuntu:latest. (you should also tag with a specific version number so that you can still reference the image when you update :latest)
Then docker push myaccount/ubuntu.
It won't actually make a copy, but it will add the new tag to the existing image. Other people won't see the tag unless they docker pull myaccount/ubuntu.
Macos Use the command
$ docker pull NAME:tag
$ docker tag NAME:tag myaccount/name:tag
$ docker login
# yourname
# password
$ docker push myaccount/name:tag