Installation docker && dockerfile prepared using conventional image springbootdemo

dockerfile Reference Guide
 
docker container to create command:
docker run -d -p 10002:8080 --name springdemo springdemo
 
-d: background
-p: set up port mapping
--name: container named
 
Description: Mirror only run once loaded into the container, the container is managed by a subsequent start, stop and restart commands
 
 
Docker container into the inside:
Recommended exec, because with attach, quit after the container will also withdraw together
docker exec -it mynginx /bin/sh /root/runoob.sh
 
-i: Even without additional remains open STDIN
-t: assign a pseudo-terminal
 
dockerfile examples

Description: pre-download the JDK from oracle official website jdk-8u181-linux-x64.tar.gz. Ready need to package the project jar package (I made a project without any logical springboot) justspringdemo-1.0-SNAPSHOT.jar (I was coming through maven install packaged)  
 
# Version information
 the FROM CentOS
 the MAINTAINER on Danny 
 
# the OS environment configuration 
# the RUN yum the install wget -Y 
 
# install the JDK 
the RUN mkdir / var / tmp / JDK
 COPY JDK-8u181-Linux-x64.tar.gz / var / tmp / JDK
 the RUN the tar the xzf -C /var/tmp/jdk/jdk-8u181-linux-x64.tar.gz / var / tmp / RM -rf /var/tmp/jdk/jdk-8u111-linux-x64.tar.gz JDK && 
 
# set environment variable 
ENV JAVA_HOME /var/tmp/jdk/jdk1.8 .0_181
 ENV the PATH $ the PATH: $ JAVA_HOME / bin 
 
# package the project and copied to the tomcat webapps directory 
cOPY justspringdemo-1.0 -SNAPSHOT.jar / Home
 RUN cd / Home 
 
# open internal service port 
EXPOSE 8080
 
# Start the tomcat server 
CMD the Java -jar justspringdemo-1.0-SNAPSHOT.jar
Create a custom image docker build command:
docker build -f springdemo_dockerfile -t springdemo .
 
-f: Specifies the dockerfile script to be executed. If you do not use the -f parameter, docker will automatically find the default file name: Dockerfile
-t: Specifies the image name and version number

Guess you like

Origin www.cnblogs.com/danny-djy/p/10947948.html