Dockerfile mirrored

Dockerfile Profile

dockerfile is a text configuration file format, you can use Dockerfile to quickly create a custom image,

   In addition, the use of Dockerfile to build using a mirror like pom to build maven projects, with the same purpose

dockerfile basic structure
Dockerfile command statement consists of rows and supports # comment lines begin with, in general, divided into four parts Dockerfile body:
the base image information, perform a maintainer information, instructions and image containers start command.

Some commands 
   base image information FROM 
   maintainer information MAINTAINER 
   mirroring operation instruction the RUN, (COPY / the ADD), EXPOSE, the WORKDIR, ONBUILD, the USER, the VOLUME other 
   execution start command CMD container, ENTRYPOINT

3. docker container using Dockerfile create jdk
0.5 start the virtual machine, enter centos

1. Create a folder to upload jdk installation package, and write files in the same directory Dockerfile
# 1. Create a mirrored directory
mkdir -p / javaxl_docker / jdk
# 1. Installation lrzsz command
yum install -y lrzsz
# 1. Select the file Upload
rz
# Note d uppercase
touch Dockerfile

 

 

  2. Write Dockerfile file

# 1 Specifies the base image, and must be the first instruction 
        RROM CentOS: . 7 

        # 2 . Specify the e-mail of its mirror image and 
        the MAINTAINER on ZS " [email protected] " 

        # . 3 . When constructing a mirror, mirrored designated working directory after directory commands are based on this work, and if not, it will create a directory 
        WORKDIR / jt_docker / jdk 

        # 4 a copy command to copy the installation files jdk to the mirror, the syntax:. ADD <src> .. . <dest>, Note: * JDK .tar.gz relative path using 
        the ADD JDK -8u221-Linux-x64.tar.gz / jt_docker / JDK / 

        # . 5 configure the environment variables. 
        ENV the JAVA_HOME = / jt_docker / JDK / jdk1 . 8 .0_221 
        ENV the CLASSPATH=:. $ JAVA_HOME / lib / dt.jar: $ JAVA_HOME / lib / tools.jar 
        ENV the PATH = $ JAVA_HOME / bin: $ the PATH 

        command # container when you start to be executed 
        #CMD [ " the Java " , " -version " ]

 

 

 

3. When execution Dockerfile file, for the first time will depend on the mirror to download the appropriate image

docker build -t jdk8:v1.0 .

 

Note 1: -t jdk8: v1.0 to newly constructed mirror named jdk8, and set version v1.0
Note 2: Note that the last point has, on behalf of the current path constructed Dockerfile

 

 

 

 

4. View Mirror
docker images

5. Create and start container

      docker run -it --name myjdk01 b4d0072da9bd

 6. Check if there are problems

      java -version

 

Guess you like

Origin www.cnblogs.com/ztbk/p/12047919.html