Building new images from existing images is done through Dockerfile documents. 1. Create a new Dockerfile document Create a new folder in the /home folder specifically for testing, the /docker/test folder, and create a new Dockerfile document in the folder. Write the following content in the document: FROM ubuntu:18.04 RUN apt-get update RUN apt-get install -y vim EXPOSE 80 In a Dockerfile document, the first keyword of each line must be capitalized. The first line means that the source image of the newly created image is Ubuntu 18.04 version. The second line is the first command executed after the new image is created, which means that after the new image is created, the URLs for downloading various applications will be updated first. The third line installs vim, which is convenient for editing scripts in the command line later. -y is for automatic installation. Otherwise, the installation process will ask you to enter Y/n. If you do not enter it, the execution will fail. The fourth line at the end means exposing port 80. Like the webapp port mapping in yesterday’s article, if you perform mapping to port 5000 in this image, it will fail because this port is not open to the outside world. 2. Execute the command in the directory where the Dockerfile is located su root cd docker/test docker build -t cdl-test-0.0 . In the last sentence, -t is followed by the specified image name, and the image name is followed by a dot, which means that a new image is created using the content in the Dockerfile in the current directory. So please note that the dot at the end of the previous cd command and this sentence is indispensable! ! 3. View the new image docker images result: REPOSITORY TAG IMAGE ID CREATED SIZE cdl-test-0.0 latest da5d6c1147a7 4 minutes ago 185MB runoob/centos 6.7 542cf01e7692 27 minutes ago 191MB ubuntu 16.04 52b10959e8aa 5 days ago 115MB ubuntu 18.04 16508e5c265d 5 days ago 84.1MB centos 6.7 f2e2f7b8308b 3 weeks ago 191MB training/webapp latest 6fae60ef3446 3 years ago 349MB 4. View the applications installed in the image #Enter the command line of the newly created image docker run -it cdl-test-0.0 /bin/bash #Open vim vim #Install python3.7 apt-get install python3.7 The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Configure Mysql master-slave service implementation example
>>: WeChat applet custom tabbar component
Table of contents 【Effect】 【Implementation method...
You know that without it, the browser will use qui...
The main contents of this article are as follows:...
This article will not explain the use and install...
I found an example when I was looking for a way t...
"What's wrong?" Unless you are accus...
HTML code: <a onclick="goMessage();"...
1. What is the use of slow query? It can record a...
Table of contents Overview Application scenarios ...
Introduction to Positioning in CSS position attri...
Preface What is a slow query and how to optimize ...
Table of contents 1. Docker enables remote access...
Preface When I went to an interview at a company ...
cursor A cursor is a method used to view or proce...
Table of contents mysql filtered replication Impl...