DockerCompose purpose: to simplify Docker start and stop processes, and the relationship between choreography Docker start the service with the service
DockerCompose的安装:curl -L https://get.daocloud.io/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose version
curl -L https://github.com/docker/compose/releases/download/1.24.0/docker-compose-`uname -s`-`uname -m`>/usr/local/bin/docker-compose
Write docker-compose.yml file, with the same format springboot written in the configuration file, but can not use the tab key to indent when writing yml file, do not believe you can try
Write a simple configuration tomcat startup configuration file
version: '3.1' services: tomcat: restart: always image: tomcat container_name: tomcat ports: - 8080:8080
Start command: execution docker-compose up will be able to start running tomcat -d background in the current folder
Stop Command: docker-compose down the command stops and clear the vessel in order to start recording docker-compose form of a container
After a file vi:: set paste Paste command as it re-entered in the format i will be able to copy and paste AS
The following operations are in / usr / local / folder under the following operating, follow the linux folder specified operating range if you do not want to change elsewhere in the folder does not matter
Tomcat deployment
1.docker-compose.yml
version: '3.1' services: tomcat: restart: always image: tomcat container_name: tomcat ports: - 8080:8080 volumes: - ./webapps:/usr/local/tomcat/webapps environment: TZ: Asia/Shanghai
2. Run the docker-compose up -d
At this point in the directory where you will generate a folder webapps, this folder is called data volumes, this position in the vessel
/ Usr / local / tomcat / webapps position shared memory, which means that both the contents of the file folder are the same, so do not worry about the container is closed, the application data persistence problem
Even if the container delete this data will still be retained
Deployment mysql
1.docker-compose.yml
version: '3.1' services: db: # 目前 latest 版本为 MySQL8.x image: mysql restart: always environment: MYSQL_ROOT_PASSWORD: 123456 command: --default-authentication-plugin=mysql_native_password --character-set-server=utf8mb4 --collation-server=utf8mb4_general_ci --explicit_defaults_for_timestamp=true --lower_case_table_names=1 ports: - 3306:3306 volumes: - ./data:/var/lib/mysql # MySQL 的 Web 客户端 adminer: image: adminer restart: always ports: - 8080:8080
2. Same as tomcat, docker creates a container with the data in the local shared memory space
So far tomcat and mysql already deployed, as to how to deploy the project, I think you do not need me to say it?
Briefly about: First, the project lay in the war package extract to remove the extra generated under tomcat webapps folder files, the database initialization statements and historical data to perform the import, start two containers on it.