In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "how to build a new image based on the existing image in Docker". The content is easy to understand and clear. I hope it can help you solve your doubts. Let the editor lead you to study and learn the article "how to build a new image based on the existing image in Docker".
Building a new image from an existing image is done through an Dockerfile document.
1. Create a new Dockerfile document
Create a new folder under the / home folder specifically for testing, / docker/test folder, create a new Dockerfile document in the folder, and write the following:
FROM ubuntu:18.04RUN apt-get updateRUN apt-get install-y vimEXPOSE 80
In an Dockerfile document, the first keyword of each line must be capitalized.
The first line means that the source image of the new mirror is Ubuntu version 18.04.
The second line is the first command executed after creating a new image, indicating that after creating a new image, first update the URLs of subsequent downloads of various applications.
The third line is to install vim to facilitate subsequent editing of the script on the command line,-y is to allow it to install automatically, otherwise the installation process will let you type YPay, if you do not enter, the execution will fail.
The last fourth line means to expose port 80, like the webapp port mapping in yesterday's article, if you perform the mapping to port 5000 in this mirror, it will fail because the port is not open to the public.
2. Execute the command in the directory where Dockerfile is located
Su rootcd docker/testdocker build-t cdl-test-0.0.
In the last sentence,-t is followed by the specified image name, followed by a dot, indicating that the new image is created through the contents of the Dockerfile in the current directory, so note that the previous cd command and the last dot of this sentence can not be less!
3. View the new image
Docker images
Results:
REPOSITORY TAG IMAGE ID CREATED SIZEcdl-test-0.0 latest da5d6c1147a7 4 minutes ago 185MBrunoob/centos 6.7 542cf01e7692 27 minutes ago 191MBubuntu 16.04 52b10959e8aa 5 days ago 115MBubuntu 18.04 16508e5c265d 5 days ago 84.1MBcentos 6.7 f2e2f7b8308b 3 weeks ago 191MBtraining/webapp latest 6fae60ef3446 3 years ago 349MB
4. View the applications installed in the image
# enter the command line docker run-it cdl-test-0.0 / bin/bash# to create a new image and open vimvim# to install python3.7apt-get install python3.7. The above is all the contents of the article "how to build a new image based on an existing image by Docker". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.