- docker container installation;
docker offline version:
wget https://download.docker.com/linux/static/stable/x86_64/docker-20.10.14.tgz
After the download is complete, unzip the tar package:
tar -zxvf docker-20.10.14.tgz
Copy the relevant commands to /usr/bin/
cp docker/* /usr/bin/
Register the docker service as a system service:
First create docker.service
vim /etc/systemd/system/docker.service
Paste the following into it:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
Add execution permissions to the docker.service file:
chmod +x /etc/systemd/system/docker.service
Reload the configuration file: (reload every time you modify the docker.service file)
systemctl daemon-reload
Start the docker service:
systemctl start docker.service
Set up to start automatically:
systemctl enable docker.service
View status:
systemctl status docker
Check docker version:
docker -v
Test after installation:
To configure the mirror accelerator, you can use the accelerator of the University of Science and Technology of China:
tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
EOF
Refresh configuration:
systemctl daemon-reload
Restart docker:
systemctl restart docker
Pull mirror:
docker pull XXX (image name)
View all images:
docker images
Docker uses EPEL to release, you need to ensure that there is an EPEL warehouse, first install the corresponding EPEL package:
yum install -y epel-release
Install docker:
yum install -y docker-io
View the configuration file after installation: cat /etc/sysconfig/docker
Start the Docker background service: service docker start
Verification: docker version
Set docker to start automatically: chkconfig docker on
Docker checks whether it starts automatically after booting: chkconfig docker --list
- Pull the tomcat image
docker pull tomcat
After the image pull is complete:
Set the mapped port through the -p parameter at startup:
docker run -d -p 8888:8080 tomcat
(map port 8888 of the virtual machine to port 8080 in the container)
When accessing, you can directly access port 8888 (you can set it according to actual needs)
Virtual machine ip+virtual machine port
For example: 172.16.6.130:8888/
Check if the container is running properly:
docker ps (can also display the ID corresponding to each running image)
Visit 172.16.6.130:8888/ tomcat service background, if there is a 404 error
Should not be able to find the home page
At this point, you need to enter the tomcat image:
docker exec -it ID /bin/bash
Entering the directory will find a webapps.dist
Next rename webapps.dist to webapps
Order:
mv weapps.dist ./webapps
At this time, you can enter the webapps directory and find that the directory is not empty:
re-access the browser, if you still cannot access the tomcat console
Restart the tomcat container:
Systemctl restart tomcat
Just visit again