Explain in detail the working principle and usage of the Docker image submission command commit
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.
Let's put it into practice.
Docker pull nginx:1.15.3
Start a container with the command line:
Docker run-d-p 1080 docker run-- name jerry-nginx nginx:1.15.3
Localhost:1080
Enter the shell of the container:
Docker exec-it jerry-nginx / bin/bash
Check the default home page of this nginx image:
I want to use wget in the container, so install it first:
Apt-get update & & apt-get-y install wget
Use the wget command to download an image file and a html file to the location of the Nginx server where the web page is stored:
Wget-- no-check-certificate-O / usr/share/nginx/html/evil.jpg https://github.com/raw/slvi/docker-k8s-training/master/docker/res/evil.jpgwget-- no-check-certificate-O / usr/share/nginx/html/index.html https://github.com/raw/slvi/docker-k8s-training/master/docker/res/evil.html
Refresh the page, and the page we see now has become the page downloaded by wget:
We now want to solidify the changes found in this container so that others can use it.
Docker commit jerry-nginx jerry-modify-nginx:1.0
Use the command to set 1.0 to latest tag:
Docker tag jerry-modify-nginx:1.0 jerry-modify-nginx:latest
Stop the old container with docker stop jerry-nginx, and then start the modified container jerry-modify-nginx:
Docker history name to view the history of this new image:
Execute the command to label the new image:
Docker tag jerry-modify-nginx:latest registry.ingress.shcw46.k8s-train.shoot.canary.k8s-hana.ondemand.com/jerry-modify-nginx:760d7ca6
Push the tagged image to the remote end:
Docker push registry.ingress.shcw46.k8s-train.shoot.canary.k8s-hana.ondemand.com/jerry-modify-nginx:760d7ca6
The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.