In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
Most people do not understand the knowledge points of this article "how to use docker commit in Docker image construction", so the editor summarizes the following content, detailed content, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use docker commit in Docker image construction" article.
We can pull the image through the public warehouse, but sometimes the image pulled by the public warehouse does not meet our needs. Although we have been freed from the tedious deployment work, in actual development, we may want to mirror the complete environment that contains the entire project, pull the packaged complete image on other machines, and run it directly.
Docker supports self-building images and uploading self-built images to a public repository. Image construction can be achieved in the following two ways:
Docker commit: create a new image from the container
Docker huild: create an image with Dockerfile file
Example: build the image through docker commit, and install jdk and Tomcat in the basic image centos:7 to make a new image.
1. Create a container # pull an image docker pull centos:7# to create a container docker run-id-- name centos7 centos:72, copy resources
Copy the host's jdk and Tomcat to the container
Docker cp jdk-11.0.7_linux-x64_bin.tar.gz centos7:/rootdocker cp apache-tomcat-9.0.39.tar.gz centos7:/root3, installation Resources # enter the container docker exec-it centos7 / bin/bash
Do the following in the container:
# change to / root directory cd root/# create Java and Tomcat directories mkdir-p / usr/local/javamkdir-p / usr/local/tomcat# extract jdk and Tomcat to container Java and Tomcat directories tar-zxvf jdk-11.0.6_linux-x64_bin.tar.gz-C / usr/local/Java/tar-zxvf apache-tomcat-9.0.39.tar.gz-C / usr/local/tomcat/# in the environment variable file Add the following to the export JAVA_HOME=/usr/local/java/jdk-11.0.6/export PATH=$PATH:$JAVA_HOME/bin# reload environment variable file source / etc/profile# to test whether the environment variable is configured successfully [root@f1cd1a3df1ed etc] # java-versionjava version "11.0.7" 2020-04-14 LTSJava (TM) SE Runtime Environment 18.9 (build 11.0.7+8-LTS) Java HotSpot (TM) 64-Bit Server VM 18.9 (build 11.0.7+8-LTS Mixed mode) 4. Build an image docker commit [OPTIONS] CONTAINER [REPOSITORY [: TAG]] docker commit-a = "xiaoyang"-m = "jdk11 and tomcat" centos7 mycentos:7
-a: submitted mirror author
-c: use the Dockerfile directive to create a mirror
-m: description text at the time of submission
-p: pause the container during commit
5 、 Create a container using the built image # create container docker run-id-- name mycentos7-p 8080 mycentos:7# enter container docker exec-it mycentos7 / bin/bash# reload configuration file source / etc/profile# test Java environment variable [root@7ed6a969f63a /] # java-versionjava version "11.0.7" 2020-04-14 LTSJava (TM) SE Runtime Environment 18.9 (build 11.0.7+8-LTS) Java HotSpot (TM) 64-Bit Server VM 18.9 (build 11.0.7+8-LTS Mixed mode) # starting Tomcat/usr//local/tomcat/apache-tomcat-9.0.39/bin/startup.sh is the content of this article on "how to use docker commit in Docker Image Construction" I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to 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.