Install docker, mysql, jdk, start the project in the ultimate offline situation

Install docker, mysql, jdk, start the project in the ultimate offline situation

Many government projects are in a closed network environment. For this situation, we cannot directly obtain some software through the network when we install some software using Linux. Today I will talk about how to do this in an offline situation.

1. Install docker offline

In fact, installing docker offline is very simple, there are also many tutorials on the Internet, I will also talk about it.
1. First download a docker installation package on a computer with internet. Download the docker installation package (there are many, you need to download 3 files of the same version)
Insert picture description here
2. Use the filezilla tool to save the installation package in a certain folder of the linux system and enter the folder.

3. To install docker, install these three packages separately in order. If the order is in order, you will be prompted during the installation. If the order is wrong, it will prompt you to have dependent packages.
Insert picture description here
4. After the installation is complete, check that the docker service has been started: ps -aux | grep docker
5. If the service is not started, systemctl start dockerstart the docker service.
6. Docker info view docker information.

This completes the offline installation of docker.

Two, install mysql mirror

After successfully installing docker, it is very convenient to use docker to install the mysql image.
1. First, you have to get a mysql image file, which can be downloaded online or packaged and exported in the docker that has the mysql image.
Export method:Docker save -o 包名.tar 镜像名称:镜像版本号

Docker save - o mysql.tar docker.io/centos/mysql-57-centos7: latest

2. The general export location is in the /root directory. You can also find it.

Find / -name 报名.tar
Find/ -name mysql.tar

3. Copy the package to another server without network (/root directory), enter the directory, and use docker to load the image.

   Docker load -i 包名.tar
   Docker load -i mysql.tar 

4. View the mirror docker images

5. Start the image and load it as a container (for mysql image)

sudo docker run --name pwc-mysql -e MYSQL_ROOT_PASSWORD=123456 -p 3306:3306 -d 镜像名称  

6. Start the container docker start 容器id

This completes the offline installation of the mysql mirror.

Three, install jdk mirror

Installing jdk mirroring is the same as installing mysql mirroring, except that there is a little difference in starting the mirroring.
Mark the image into a container:

docker  run -d -p 9999:8080 -it 镜像名称:版本号 /bin/bash

Fourth, start the project

1. The first step is to start docker internally one by one mirror files, so we must first make the project jar into a mirror.

  • a. Construction of mirroring statement docker build -t <镜像名> -f <Dockerfile路径>
    This statement is used to build their own image, and start this statement, docker engine by Dockerfile path you define Dockerfile to find your file.

  • b. Write Dockerfile

  • FROM hub.c.163.com/housan993/centos7_jdk8

  • MAINTAINER YYL

  • ADD mul_user_management.jar /opt

  • WORKDIR /opt EXPOSE 9500

  • CMD java -Duser.timezone=GMT+8 -jar mul_user_management.jar --server.port=9500

  • FROM is the first statement in the Dockerfile and is an indispensable statement. FROM is used to define a basic image FROM <image>或者 FROM <image>:<tag>.

  • The basic mirror can be any mirror that already exists. It can be understood that FROM will take the basic mirror you defined and use it as a model to develop on its basis, so the basic mirror is indispensable.

  • The
    format of MAINTAINER is to MAINTAINER user_name user_email 或者 2.MAINTAINER namespecify maintainer information

  • ADD ADD <src> <dest>copies the specified src to the dest of the container. src can be a relative path of the directory where the Dockerfile is located; it can be a URL or tar (automatically decompressed)

  • WORKDIR: Specify the current working directory, equivalent to cd WORKDIR /path/to/workdir

CMD supports three formats:
CMD ["executable","param1","param2"] Use exec to execute, the recommended way;
CMD command param1 param2 is executed in /bin/bash and is provided to applications that need interaction;
CMD ["param1" ,"Param2"] is the default parameter provided to ENTRYPOINT;

Specify the command to be executed when the container is started. Each Dockerfile can only have one CMD command. If multiple commands are specified, only the last one will be executed. If the user specifies a command to run when starting the container, the command specified by CMD will be overwritten.

The above is to prepare a simple Dockerfile.
Then just use docker docker build -t <镜像名> -f <Dockerfile路径>. Note that if
docker build -t <镜像名> .the location of the Dockerfile file is not specified, add a',', which means that Dockerfile is the current file path by default.

After the image is built, just start the image.
docker run -d --Image name file -p defines the port number 0000:0000

ps: some basic docker commands docker basic commands

Guess you like

Origin blog.csdn.net/qq_31142237/article/details/93595560