@[TOC](Docker install Jdk, Mysql, Nginx, Redis, Tomcat)
Recommend personal Docker articles, very detailed
【 Docker container 1】Dockerd details and installation
Build Jdk, Mysql, Nginx, Redis, Tomcat environment based on Docker in one minute
Deploy the SpringBoot project based on Docker
【 Docker container 4】 Build Docker private server based on Docker, and how to use Docker private server details
How to build Maven private server based on Docker, and how to use Maven private server
Build GitLab management code based on Docker
Automatic construction, deployment, testing and monitoring of projects based on Docker installation Jenkins
What are the benefits of using the Docker installation environment
Mysql, Tomcat, Nginx, JDK, Redis, MQ, Git Lab, Node, etc. All have second install level 3. You can’t configure it in detail, you have to do it yourself, but you can configure it and package it into a mirror, and then use it next time
1. Configure the mirror accelerator
In China, Aliyun and 163 both provide Docker warehouses, but Aliyun also provides acceleration functions. Therefore, we choose ali Cloud acceleration. Warehouse address of 163: c.163.com/hub#/m/home…
If you do not configure the mirror accelerator, the network is very slow, the fastest speed is only 100-200K to configure the ali Cloud accelerator, the speed can reach dozens of meters, so there is no reason not to configure
1. Open aliyun website
2. Log in to the container image console
If you do not have an account, register an account first. After successful login, go to the console in the upper right corner. On the console page, go to the products and services in the upper left corner –> Search containers –> find the container services below
It may appear, select “Go to RAM for authorization” from the image below, then click “Agree to authorize” from the popup screen.
Locate the image in the lower left corner and select the container Image console in the upper right corner
Go to the bottom left corner of the mirror accelerator, click on CentOS.
3. Configure the Linux image Accelerator
The method of using the loader is indicated in the figure above. Let’s select all of the following code into the Xshell tool and hit Enter. Notice that there are four commands,
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://jrvh6o0l.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Copy the code
2. Use Docker to install Jdk8
1. Search for mirrors
docker search java
Copy the code
The docker search command searches for images stored in the Docker Hub. After executing this command, Docker will search the Docker Hub for the image repository containing the keyword Java.Docker Hub官网 Docker Hub官网 Docker Hub官网hub.docker.com/
2. Download the image
docker pull java:8
Copy the code
This command will download the image from the Docker Registry. Docker pull Java :8 is used to download the JDK with the specified version number, if not :8, the default is to download the latest versionAt this point, you can list the containers to see if the JDK8 image downloaded successfully
docker images
Copy the code
3. Start the container
Docker run -d it --name Java Java :8 # docker run -d it --name Java :8 #Copy the code
Docker ps -a to view all containers, including those that are not running.
docker ps
Copy the code
It turns out that we have a container named Java running, and we’re done here. successful
3. Install Mysql using Docker
1. Look for Mysql
docker search mysql
Copy the code
2. Download the MySQL5.7 image
Docker pull mysql: 5.7Copy the code
3. Create a mysql container
Mysql/Docker/Linux/Docker/Linux/Docker
Mysql docker run -p 3303:3306 --name mysql3303 -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7Copy the code
Why map port numbers?Because Docker container and Linux system port one inside and one outside, so to map to the external Linux system port, if not mapped, can only be used in the container
-p 3303:3306 The first port number is the Linux port number, and the second port number is the internal port number of the Docker container
The Docker container has been opened successfully.
4. Use SQLyou to connect to Mysql
1. Find the LP address of Linux and skip it if you know the IP address
Systemctl stop firewalld Run the ifconfig command to view the IP address ifconfigCopy the code
If it is Ali cloud server, find your server public IP address, and open open 3303 port number specific steps access:Ali cloud server is configured for Internet accessTo open port 3303
2. Test the connection by entering the IP address and port number 3303successful
4. Install Nginx using Docker
1. Download the Nginx image and start the Nginx container
Install Nginx with a command
docker run -d -p 81:80 nginx
Copy the code
Docker run -d -p 81:80 nginx: version number
Why is this single command able to download Nginx to the end of installation? If you can’t find a jar file, you can download it from the Docker Hub, and then automatically deploy Nginx. If you can’t find a jar file, you can download it from the Docker Hub, and then use it again.
Why map port numbers? Because Docker container and Linux system port one inside and one outside, so to map to the external Linux system port, if not mapped, can only be used in the container
-p 81:80 is the mapping configuration port number of the Docker container. The first port number is the Linux port number. The second port number is the internal port number of the Docker container
2. Access Nginx from the Internet
Find the LP address of Linux first and skip the IP address if you know it
Systemctl stop firewalld Run the ifconfig command to view the IP address ifconfigCopy the code
If it is Ali cloud server, find your server public IP address, and open open 81 port number specific steps access:Ali cloud server is configured for Internet accessTo open port 81access
Success!
5. Install Tomcat using Docker
1. Download the Tomcat image and start the Tomcat container
A command solution
docker run -d -p 8080:8080 --name mytomcat tomcat:9
Copy the code
Docker run -d -p 8080:8080 –name mytomcat tomcat: specifies the version number Why can this single command be used to download Tomcat to the end of installation?When Tomcat is started, it will automatically search for the image file, and if it is not found, it will automatically download Tomcat from the Docker Hub. It is similar to Maven. If you cannot find jar package locally, you will download it from the Docker Hub and use it again.
Why map port numbers? Because Docker container and Linux system port one inside and one outside, so to map to the external Linux system port, if not mapped, can only be used in the container
-p 8081:8080 indicates the mapping configuration port number of the Docker container. The first port number is the Linux port number, and the second port number is the Docker port number
2. Access Tomcat from the Internet
Find the LP address of Linux first and skip the IP address if you know it
Systemctl stop firewalld Run the ifconfig command to view the IP address ifconfigCopy the code
If it is Ali cloud server, find your server public IP address, and open open 8080 port number specific steps access:Ali cloud server is configured for Internet accessTo open port 8080access
Success!
6. Install Redis using Docker
1. Download the Redis image and start the Redis container
A command solution
docker run -d -p 16379:6379 --name redis redis:3
Copy the code
Docker run -d -p 16379:6379 –name redis redis: specifies the version number Why does this single command enable Redis to download to the end of the installation?If you can’t find the jar package in Maven, you can download it from the Docker Hub. If you can’t find the jar package in Maven, you can download it from Maven and use it in Maven.
Why map port numbers? Because Docker container and Linux system port one inside and one outside, so to map to the external Linux system port, if not mapped, can only be used in the container
-p 16379:6379 indicates the mapping configuration port number. The first port number is the Linux port number. The second port number is the internal port number of the Docker container
2. Use RedisDesktopManager to connect to Redis
Find the LP address of Linux first and skip the IP address if you know it
Systemctl stop firewalld Run the ifconfig command to view the IP address ifconfigCopy the code
If it is Ali cloud server, find your server public IP address, and open open 16379 port number specific steps access:Ali cloud server is configured for Internet accessTo open port 16379The connection
Success!
What if there is an error along the way
1. Run the logs command provided by Docker to view container run logs
Start by checking which containers are running Docker PSCopy the code
View run logs by container ID. For example, if I view Tomcat logs, enter docker logs container IDCopy the code
2. Recommend to solve the Docker Bug website, there are questions must answer
Click to enter