Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to submit an image DockerCommit and push an image DockerPush through the container

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to submit an image DockerCommit and push an image DockerPush through the container. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

After creating a container locally, you can create a local image based on the container, and push the image to Docker hub for download and use on the network.

View the image [root@docker-test1 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/ubuntu 16.047aa3602ab41e 5 weeks ago 115MB to create a container called myubuntu [root@docker-test1 ~] # docker run-ti-- name myubuntu-d docker.io/ubuntu [root@docker-test1 ~] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES651a8541a47d docker.io/ubuntu "/ bin/bash" 37 seconds ago Up 36 seconds myubuntu docker commit: create a new image from the container. # docker commit [OPTIONS] CONTAINER [REPOSITORY [: TAG]]-a: the author of the submitted image;-c: use the Dockerfile instruction to create the image;-m: the description at the time of submission;-p: pause the container during commit. Submit the image according to this myubuntu container [root@docker-test1 ~] # docker commit-a "wangshibo"-m "this is test" 651a8541a47d myubuntu:v1sha256:6ce4aedd12cda693d0bbb857cc443a56f9f569106e09ec61aa53563d0932ea4d to view the image again It is found that the image myubuntu:v1 has been submitted locally [root@docker-test1 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmyubuntu v1 6ce4aedd12cd 59 seconds ago 84.1 MBdocker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB pushed to docker hub in mybuntu:v1 image Go to # docker push [OPTIONS] NAME [: TAG] OPTIONS in the repository description:-- disable-content-trust: ignore the check of the image The default is to log in to docker hub (user name: wangshibo password: *) [root@docker-test1 ~] # docker loginLogin with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.Username (wangshibo): wangshiboPassword:Login Succeeded [root@docker-test1 ~] # docker push wangshibo/myubuntu:v1The push refers to a repository [docker.io/wangshibo/myubuntu] An image does not exist locally with the tag: docker.io/wangshibo/myubuntu. Here you need to rename the ubuntu:v1 image and add your own docker hub Docker ID before the name. Namely wangshibo [root@docker-test1 ~] # docker tag 6ce4aedd12cd wangshibo/myubuntu:v1 [root@docker-test1 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmyubuntu v1 6ce4aedd12cd 6 minutes ago 84.1 MBwangshibo/myubuntu v1 6ce4aedd12cd 6 minutes ago 84.1 MBdocker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB push again (Note: the tag tag of v1 below can be left untyped The default is latest). The push operation time will be a little longer. Wait patiently for ~ [root@docker-test1 ~] # docker push wangshibo/myubuntu:v1 The push refers to a repository [docker.io/wangshibo/myubuntu] b5948ba9486d: Pushed8d7ea83e3c62: Mounted from library/ubuntu6a061ee02432: Mounted from library/ubuntuf73b2816c52a: Mounted from library/ubuntu6267b420796f: Mounted from library/ubuntua30b835850bf: Mounted from library/ubuntuv1: digest: sha256:e9cd9075d262848a307c92751e1a5890d883b814a31abd118161442461a1ca2d size: 1564. finally log in to your Docker Hub, that is, after https://hub.docker.com/ logs in In Repositories, you can see the image wangshibo/myubuntu:v1 you pushed above. This is an external image that can be downloaded on the network. You can see the download command for this image on Docker hub (note that you follow the tag tag when downloading If it is the default tag of latest, you can also delete this image directly on Docker hub (Repositories- image-Settings-delete). For example, download this image on another server [root@kevin-test ~] # docker pull wangshibo/myubuntuPulling repository wangshibo/myubuntuRepository not found needs to follow the tag tag [root@kevin-test ~] # docker pull wangshibo/myubuntu:v1v1: Pulling from wangshibo/myubuntu68e2a091ef24: Pull complete8f9dd35f6299: Pull completea81a6171600b: Pull completea211a2bc7010: Pull complete9e71a0b4f83a: Pull complete0cf75bb335aa: Pull completec393a882769e: Pull completeDigest: sha256:845fa3dcc9d0de1b9c701e1009918995da35a29012015f6c297a05edc489e018Status: Downloaded newer image for wangshibo/myubuntu:v1 [root@kevin-test ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEwangshibo/myubuntu v1 c393a882769e 12 minutes ago 84.11 MB delete this image [root@docker-test1 ~] # docker imagesREPOSITORY TAG IMAGE locally ID CREATED SIZEmyubuntu v1 6ce4aedd12cd 15 minutes ago 84.1 MBwangshibo/myubuntu v1 6ce4aedd12cd 15 minutes ago 84.1 MBdocker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB notice that there are two 6ce4aedd12cd mirrored ID above If you directly use this image ID, you can't delete it. [root@docker-test1 ~] # docker rmi 6ce4aedd12cdError response from daemon: conflict: unable to delete 6ce4aedd12cd (must be forced)-image is referenced in multiple repositories should first delete the image before the docker tag is renamed, and delete it using the image name. (usually after the docker tag image is renamed It is best to delete the image before renaming) [root@docker-test1 ~] # docker rmi myubuntu:v1Untagged: myubuntu:v1Untagged: wangshibo/myubuntu@sha256:e9cd9075d262848a307c92751e1a5890d883b814a31abd118161442461a1ca2d [root@docker-test1 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEwangshibo/myubuntu v1 6ce4aedd12cd 15 minutes ago 84.1 MBdocker.io/ubuntu 16.047aa3602ab41e 5 weeks ago 115MB you can delete the image ID at this time. Delete [root@docker-test1 ~] # docker rmi 6ce4aedd12cdUntagged: wangshibo/myubuntu:v1Deleted: sha256:6ce4aedd12cda693d0bbb857cc443a56f9f569106e09ec61aa53563d0932ea4dDeleted: sha256:0ddeb6a16badd042914c2e72b9ef0331550c1cdcc4bdc6650a90cd9f57f1501b [root@docker-test1 ~] # docker images REPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/ubuntu 16.047aa3602ab41e 5 weeks ago 115MB

Failed to delete image: a sharing example

[root@docker-test1 ~] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES [root@docker-test1 ~] # docker ps-aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES intends to delete the nginx image of docker But I found that this image just can't be deleted. Added-f forced deletion is not good, has been reported to Error: No such image error, and finally found a way to delete files directly! [root@docker-test1 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnginx latest 62f816a209e6 7 days ago 109MB [root@docker-test1 ~] # docker rmi nginxError: No such image: nginx [root@docker-test1 ~] # docker rmi 62f816a209e6Error: No such image: 62f816a209e6 [root@docker-test1 ~] # docker rmi 62f816a209e6-fError: No such image: 62f816a209e6 as above I can't delete the nginx image! Solution: [root@docker-test1 ~] # systemctl stop docker [root@docker-test1 ~] # rm-rf / var/lib/dockerrm: cannot remove'/ var/lib/docker/containers': Device or resource busy cannot be deleted because the corresponding directory is mounted and not uninstalled when the container is established So Device or resource busy solution: find the mounted directory and uninstall [root@docker-test1 ~] # cat / proc/mounts | grep "docker" / dev/mapper/centos-root / var/lib/docker/containers xfs rw,relatime,attr2,inode64,noquota 0 0proc / run/docker/netns/default proc rw,nosuid,nodev,noexec,relatime 0 0proc / run/docker/netns/a0626c54fd03 proc rw,nosuid,nodev,noexec,relatime 0 0proc / run/docker/netns/b18072de4224 proc rw,nosuid,nodev,noexec Relatime 0 0proc / run/docker/netns/b5298f643455 proc rw,nosuid,nodev,noexec,relatime 0 0proc / run/docker/netns/9f5e97637c98 proc rw,nosuid,nodev,noexec Relatime 0 [root@docker-test1 ~] # umount / var/lib/docker/containers [root@docker-test1 ~] # rm-rf / var/lib/docker [root@docker-test1 ~] # systemctl start docker will not have this image again. [root@docker-test1 ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE thanks for reading! This is the end of the article on "how to submit an image DockerCommit and push an image DockerPush through the container". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report