I pushed a Docker image to a remote repository, eg:
docker-dev-artifactory.XXX.XX/kafka:latest
How do I move it to
docker-dev-artifactory.XXX.XX/tomas/kafka:latest
docker tag docker-dev-artifactory.XXX.XX/kafka:latest docker-dev-artifactory.XXX.XX/tomas/kafka:latest
docker push docker-dev-artifactory.XXX.XX/tomas/kafka:latest
Related
I currently have docker image which is like this
docker.foo.com/ua/my_img:latest
I would like to make a clone of that at another repository
docker.foo.com/ub/my_cloned_img:latest
Is there any docker command that can let me duplicate the content from one address to another ?
Simply pull that docker image to your local, then tag it with another name and push:
docker pull docker.foo.com/ua/my_img:latest
docker tag docker.foo.com/ua/my_img:latest docker.foo.com/ub/my_cloned_img:latest
docker push docker.foo.com/ub/my_cloned_img:latest
Can we push different multiple images to same docker hub repository?
For example:
I have 2 images Mysql and ubuntu and only one repository name is demo.
I want to push mysql and ubuntu image to demo repository.
How can we achieve this?
consider to do it in this way (works on my side):
docker image tag your_image_name:version your_account_name_dockerhub/image_name:version
docker image push your_account_name_dockerhub/image_name:version
for example:
docker image tag nginx:latest myname/nginx:latest
docker image push myname/nginx:latest
Usually according to docs In order to build a docker Image I need to follow these steps:
Create a Dockerfile for my application.
Run docker build . Dockerfile where the . is the context of my application
The using docker run run my image into a container.
Commit my image into a container
Then using docker push push the image into a container.
Though sometimes just launching the image into a container seems like a waste of time because I can tag my images using the parameter -t into the docker build command. So there's no need to commit a container as an image.
So is neseserily to commit a running container as an image?
You don't need to run and commit. docker commit allows you to create a new image from changes made on existing container.
You do need to build and tag your image in a way that will enable you to push it.
docker build -t [registry (defaults to docker hub)]/[your repository]:[image tag] [docker file context folder]
for example:
docker build -t my-repository/some-image:image-tag .
And then:
docker push my-repository/some-image:image-tag
This will build an image from a docker file found in the current folder (where you run the docker build command). The repository in this case is my-repository, the image name is some-image and it's tag is image-tag.
Also please note that you'll have to perform docker login with your credentials to docker hub before you are able to actually push the image.
You can also tag an existing image without rebuilding it. This is useful if you want to push an existing image to a different registry or if you want to create a different image tag. for example:
docker tag my-repository/some-image:image-tag localhost:5000/my-repository/some-image:image-tag
This will add a new tag to the image from the previous example. Note the registry part added (localhost:5000). If you call docker push on that tag (docker push localhost:5000/my-repository/some-image:image-tag) the image will be pushed to a registry found on localhost:5000 (of course you need the registry up and running before trying to push).
There's no need to do so. In order to prove that you can just tag the image and push it into the registry here's an example:
I made the following Dockerfile:
FROM alpine
RUN echo "Hello" > /usr/share/hello.txt
ENTRYPOINT cat /usr/share/hello.txt
Nothing special just generates a txt file and shows its content.
Then I can build my image using tags:
docker build . -t ddesyllas/dummy:201201241200 -t ddesyllas/dummy:201201241200
And then just push them to the registry:
$ docker push ddesyllas/dummy
The push refers to repository [docker.io/ddesyllas/dummy]
1aa99de3dbec: Pushed
6bc83681f1ba: Mounted from library/alpine
201908241504: digest: sha256:93e8407b1d52620aeadd769486ef1402b9e310018cae0972760f8c1a03377c94 size: 735
1aa99de3dbec: Layer already exists
6bc83681f1ba: Layer already exists
latest: digest: sha256:93e8407b1d52620aeadd769486ef1402b9e310018cae0972760f8c1a03377c94 size: 735
And as you can see from the output you can just build the tags and push it directly, good for your ci/cd pipeline. Though, generally speaking, you may need to launch the application into a container in order to do acceptance and other type of tests (eg. end-to-end tests).
I have 2 hosts running the same docker customized image. I have modified the image on host 1 and saved the image to a custom.tar. If I take that image and load it onto host 2 will it just update or should I remove the old docker image first?
There are 2 ways to do that with repository and without repository using load and save.
With repository below are the steps.
Log in on Docker Hub
Click on Create Repository.
Choose a name and a description for your repository and click
Create.
Log into the Docker Hub from the command line
docker login --username=yourhubusername --email=youremail#company.com
tag your image
docker tag <existing-image> <hub-user>/<repo-name>[:<tag>]
Push your image to the repository you created
docker push <hub-user>/<repo-name>:<tag>
Pull the image to host 2
docker pull <hub-user>/<repo-name>:<tag>
This will add the image to docker hub and available on internet and now you can pull this image to any system.
With this approach you can keep the same images with different tags on system. But if you don't need old images better to delete that to avoid junk.
Without docker hub.
This command will create tar bundle.
docker save [OPTIONS] IMAGE [IMAGE...]
example: docker save busybox > busybox.tar
Load an image from a tar archive or STDIN
docker load [OPTIONS]
example:docker load < busybox.tar.gz
Recommended: Docker hub or DTR approach easy to manage unless you have bandwidth issue in case your file is large.
Refer:
Docker Hub Repositories
I have 2 private docker repositories. Is any way how can I copy one image from one repository to the second one?
You can pull the image, tag it and push it to the new registry.
Example:
docker pull old-registry/app:some_tag
docker tag old-registry/app:some_tag new-registry/app:some_tag
docker push new-registry/app:some_tag
Can be done with https://github.com/containers/skopeo
Example for the README:
skopeo copy docker://quay.io/buildah/stable docker://registry.internal.company.com/buildah
The advantage is that Skopeo does not require Docker on the machine it runs on.