In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the knowledge of "what is the cascading structure of docker images". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1. Introduction
When you use the docker pull sameersbn/gitlab command, you will find that you have to download a lot of images because the images of docker is cascading.
This is a bit like git. It is the uppermost layer of images, probably the next layer of images, built on the basis.
2. Docker commit
To understand this, let's take a look at an example.
We used the following command to run a nginx service before.
$docker run-- name webserver-d-p 80:80 nginx
Now let's go into this container and change something.
$docker exec-it webserver bash
Then:
Root@3729b97e8226:/# echo 'Hello, Docker' > / usr/share/nginx/html/index.htmlroot@3729b97e8226:/# exit
Use curl http://localhost again to see if the page has changed.
Then you use the stop command to stop the container, then start it again, and you will find that it has changed back to its original shape.
We modified the contents of the container earlier.
Let's see what has been changed:
$docker diff webserverC / rootA / root/.bash_historyC / runA / run/nginx.pidC / usrC / usr/shareC / usr/share/nginxC / usr/share/nginx/htmlC / usr/share/nginx/html/index.htmlC / varC / var/cacheC / var/cache/nginxA / var/cache/nginx/client_tempA / var/cache/nginx/fastcgi_tempA / var/cache/nginx/proxy_tempA / var/cache/nginx/scgi_tempA / var/cache/nginx/uwsgi_temp
We can save the changes to this container and make it a mirror image so that we can run it directly next time.
$docker commit\-- author "hfpp2012"\-- message "modified the default web page"\ webserver\ nginx:v2
Now let's take a look at the image of nginx and find that there are two, as follows:
$docker images nginxREPOSITORY TAG IMAGE ID CREATED SIZEnginx v2 f51e5af097aa 5 minutes ago 182 MBnginx latest db079554b4d2 11 days ago 182 MB
Because the v2 version of nginx image only changes the content a little bit, so the disk capacity of their two images is only 182MB more, not 182 * 2MB.
You can now run the v2 version of the nginx image.
$docker run-name web2-d-p 81:80 nginx:v23. Use docker commit cautiously
Using docker commit can save or create an image, but in general we don't use it. We use Dockerfile to build an image.
There are some disadvantages in docker commit, as can be seen in the above example. I just changed a file, but it shows a lot of changes, such as temporary files, files for recording commands (.bash _ history), and pid files.
And use docker commit to create the image, others can not know how you created, in case there is something hidden, others do not know, it is not safe.
So, we're going to use Dockerfile to create a mirror.
This is the end of the content of "what is the cascading structure of docker images?" Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.