Submit the image through the container DockerCommit and push the image DockerPush

Submit the image through the container DockerCommit and push the image DockerPush

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

View the image [root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB
 
Create a container named myubuntu [root@docker-test1 ~]# docker run -ti --name myubuntu -d docker.io/ubuntu
[root@docker-test1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
651a8541a47d docker.io/ubuntu "/bin/bash" 37 seconds ago Up 36 seconds myubuntu
 
 docker commit : Create a new image from a container.
# docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
-a: submitted mirror author;
-c: Use Dockerfile instructions to create an image;
-m: description text when submitting;
-p: Pause the container when committing.
 
Submit the image based on this myubuntu container [root@docker-test1 ~]# docker commit -a "wangshibo" -m "this is test" 651a8541a47d myubuntu:v1
sha256:6ce4aedd12cda693d0bbb857cc443a56f9f569106e09ec61aa53563d0932ea4d
 
Check the image again and find that the image myubuntu:v1 has been submitted to the local [root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myubuntu v1 6ce4aedd12cd 59 seconds ago 84.1 MB
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB
 
Push the mybuntu:v1 image to the docker hub repository # docker push [OPTIONS] NAME[:TAG]
OPTIONS description:
--disable-content-trust: Ignore image verification, enabled by default. First log in to docker hub (user name: wangshibo password: *******)
[root@docker-test1 ~]# docker login
Login 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): wangshibo
Password:
Login Succeeded
 
[root@docker-test1 ~]# docker push wangshibo/myubuntu:v1
The 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's Docker ID in front of the name, that is, wangshibo
 
[root@docker-test1 ~]# docker tag 6ce4aedd12cd wangshibo/myubuntu:v1
[root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myubuntu v1 6ce4aedd12cd 6 minutes ago 84.1 MB
wangshibo/myubuntu v1 6ce4aedd12cd 6 minutes ago 84.1 MB
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB
 
Push again (Note: the v1 tag below can be omitted, the default is latest). The push operation time will be a little long, please wait patiently~
[root@docker-test1 ~]# docker push wangshibo/myubuntu:v1           
The push refers to a repository [docker.io/wangshibo/myubuntu]
b5948ba9486d: Pushed
8d7ea83e3c62: Mounted from library/ubuntu
6a061ee02432: Mounted from library/ubuntu
f73b2816c52a: Mounted from library/ubuntu
6267b420796f: Mounted from library/ubuntu
a30b835850bf: Mounted from library/ubuntu
v1: digest: sha256:e9cd9075d262848a307c92751e1a5890d883b814a31abd118161442461a1ca2d size: 1564
 
Finally, log in to your Docker Hub, which is https://hub.docker.com/
After logging in, you can see the image wangshibo/myubuntu:v1 that you pushed above in Repositories. This is an external image and can be downloaded from the Internet.
You can see the download command of this image on Docker hub (note that you need to follow the tag when downloading, if it is the default tag of latest, you can omit it)
You can also delete this image directly on the Docker hub (Repositories-Image-Settings-delete)
 
For example, download this image on another server [root@kevin-test ~]# docker pull wangshibo/myubuntu
Pulling repository wangshibo/myubuntu
Repository not found
 
Need to keep up with the tag [root@kevin-test ~]# docker pull wangshibo/myubuntu:v1
v1: Pulling from wangshibo/myubuntu
68e2a091ef24: Pull complete
8f9dd35f6299: Pull complete
a81a6171600b: Pull complete
a211a2bc7010: Pull complete
9e71a0b4f83a: Pull complete
0cf75bb335aa: Pull complete
c393a882769e: Pull complete
Digest: sha256:845fa3dcc9d0de1b9c701e1009918995da35a29012015f6c297a05edc489e018
Status: Downloaded newer image for wangshibo/myubuntu:v1
[root@kevin-test ~]# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
wangshibo/myubuntu v1 c393a882769e 12 minutes ago 84.11 MB
 
Delete this image on this machine [root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
myubuntu v1 6ce4aedd12cd 15 minutes ago 84.1 MB
wangshibo/myubuntu v1 6ce4aedd12cd 15 minutes ago 84.1 MB
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB
 
Note that there are two image IDs of 6ce4aedd12cd above. You cannot delete the image ID by directly using it at this time [root@docker-test1 ~]# docker rmi 6ce4aedd12cd
Error response from daemon: conflict: unable to delete 6ce4aedd12cd (must be forced) - image is referenced in multiple repositories
 
You should first delete the image before the docker tag is renamed, and delete it using the image name. (Generally, after the docker tag image is renamed, it is best to delete the image before the name change)
[root@docker-test1 ~]# docker rmi myubuntu:v1
Untagged: myubuntu:v1
Untagged: wangshibo/myubuntu@sha256:e9cd9075d262848a307c92751e1a5890d883b814a31abd118161442461a1ca2d
 
[root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wangshibo/myubuntu v1 6ce4aedd12cd 15 minutes ago 84.1 MB
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB
 
At this time, you can delete the image ID [root@docker-test1 ~]# docker rmi 6ce4aedd12cd
Untagged: wangshibo/myubuntu:v1
Deleted: sha256:6ce4aedd12cda693d0bbb857cc443a56f9f569106e09ec61aa53563d0932ea4d
Deleted: sha256:0ddeb6a16badd042914c2e72b9ef0331550c1cdcc4bdc6650a90cd9f57f1501b
[root@docker-test1 ~]# docker images         
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu 16.04 7aa3602ab41e 5 weeks ago 115 MB

An example of image deletion failure

[root@docker-test1 ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker-test1 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
 
I want to delete the nginx image of docker, but I find that I can't delete it. I can't delete it by adding -f. It keeps reporting Error: No such image.
Finally found a way to delete the file directly!
 
[root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx latest 62f816a209e6 7 days ago 109MB
 
[root@docker-test1 ~]# docker rmi nginx
Error: No such image: nginx
 
[root@docker-test1 ~]# docker rmi 62f816a209e6
Error: No such image: 62f816a209e6
 
[root@docker-test1 ~]# docker rmi 62f816a209e6 -f
Error: No such image: 62f816a209e6
 
As above, I can't delete the nginx image at all!!!!
 
Solution:
[root@docker-test1 ~]# systemctl stop docker
[root@docker-test1 ~]# rm -rf /var/lib/docker
rm: cannot remove '/var/lib/docker/containers': Device or resource busy
 
The reason why it cannot be deleted is: when the container was created, the corresponding directory was mounted and not uninstalled, so Device or resource is 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 0
proc /run/docker/netns/default proc rw,nosuid,nodev,noexec,relatime 0 0
proc /run/docker/netns/a0626c54fd03 proc rw,nosuid,nodev,noexec,relatime 0 0
proc /run/docker/netns/b18072de4224 proc rw,nosuid,nodev,noexec,relatime 0 0
proc /run/docker/netns/b5298f643455 proc rw,nosuid,nodev,noexec,relatime 0 0
proc /run/docker/netns/9f5e97637c98 proc rw,nosuid,nodev,noexec,relatime 0 0
 
[root@docker-test1 ~]# umount /var/lib/docker/containers
[root@docker-test1 ~]# rm -rf /var/lib/docker
 
[root@docker-test1 ~]# systemctl start docker
 
Check again and there is no such image [root@docker-test1 ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE

The above is the details of submitting images through DockerCommit and pushing images through DockerPush. For more information about container submission and pushing images, please pay attention to other related articles on 123WORDPRESS.COM!

You may also be interested in:
  • Docker image creation Dockerfile and commit operations
  • Detailed explanation of the working principle and usage of the Docker image submission command commit
  • Docker learning notes: How to commit a container to an image
  • Detailed explanation of Docker modifying existing images (commit)
  • Detailed explanation of Docker learning to create an image using the commit command
  • Docker image commit operation example and function

<<:  Detailed explanation of json file writing format

>>:  The most creative 404 page design in history effectively improves website user experience

Recommend

Complete steps for using Nginx+Tomcat for load balancing under Windows

Preface Today, Prince will talk to you about the ...

Quickly solve the problem of slow and stuck opening of input[type=file]

Why is it that when the input tag type is file an...

An article to give you a deep understanding of Mysql triggers

Table of contents 1. When inserting or modifying ...

20 Signposts on the Road to Becoming an Excellent UI (User Interface) Designer

Introduction: Interface designer Joshua Porter pub...

What knowledge systems do web designers need?

Product designers face complex and large manufactu...

Summary of MySQL foreign key constraints and table relationships

Table of contents Foreign Key How to determine ta...

How to install and use Cockpit on CentOS 8/RHEL 8

Cockpit is a web-based server management tool ava...

How to use Docker Swarm to build WordPress

cause I once set up WordPress on Vultr, but for w...

Syntax alias problem based on delete in mysql

Table of contents MySQL delete syntax alias probl...

Steps to use autoconf to generate Makefile and compile the project

Preface Under Linux, compilation and linking requ...

A brief discussion on the mysql execution process and sequence

Table of contents 1:mysql execution process 1.1: ...

How to allow remote connection in MySql

How to allow remote connection in MySql To achiev...

How to deploy Go web applications using Docker

Table of contents Why do we need Docker? Docker d...