In order to speed up the pull, we need to set up mirroring
Set up NetEase's mirror
Edit file
vi /etc/docker/daemon.json
Add the following content to the file:
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
}
Restart docker
sudo systemctl daemon-reload
sudo systemctl restart docker
MySQL deployment
Pull mysql mirror
docker pull mysql
Create container
Description of commonly used parameters for container creation:
Create container command: docker run
-i: means running container
-t: Indicates that the container will enter its command line after it is started. After adding these two parameters, the container creation can log in. That is, a pseudo terminal is allocated.
--Name: Name the created container.
-v: indicates the directory mapping relationship (the former is the host directory, the latter is the directory mapped to the host), you can use multiple -v to do multiple directory or file mapping. Note: It is best to do directory mapping, make changes on the host, and then share to the container.
-d: Add the -d parameter after run, it will create a guardian container to run in the background (so that the container will not be automatically logged in after the container is created, if only the -i -t two parameters are added, it will automatically enter after creation container).
-p: Represents port mapping, the former is the host port, and the latter is the mapping port in the container. You can use multiple -p to do multiple port mapping
-e stands for adding environment variables
docker run -di -p 3306:3306 --name=my_mysql
-v /usr/local/mysql_data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=qwe123 mysql
MYSQL_ROOT_PASSWORD is the login password of the root user
tomcat deployment
Pull mirror
docker pull tomcat:8-jre8
Create container
docker run -di --name=mytomcat -p 9000:8080
-v /usr/local/webapps:/usr/local/tomcat/webapps tomcat:8-jre8
Then you only need to put the project war package into the host /usr/local/webapps directory, and access the host 9000 port to access the project