1. First, create the corresponding folder according to the following path /usr/local/docker/mysql 2. Then create a docker-compose.yml file in this directory and add the following configuration to the file version: '3.1' services: db: 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 --max_allowed_packet=128M; ports: -3306:3306 volumes: - ./data:/var/lib/mysql admin: image: adminer restart: always ports: - 8080:8080 3. Create the corresponding folder according to the following path /usr/local/docker/tomcat 4. Create a docker-compose.yml file in the directory of the folder and fill in the relevant configuration information (since the 8080 port of the host machine above is occupied, you can only change it to another port here) version: '3.1' services: tomcat: restart: always image: tomcat container_name: tomcat ports: -8082:8080 volumes: - /usr/local/docker/tomcat:/usr/local/tomcat/webapps/ROOT environment: TZ: Asia/Shanghai Note: If the created directories are different, the corresponding /usr/local/docker/tomcat directories above cannot be the same 5. If it fails to start, you can try it directly with the startup command docker run -p 8082:8080 image id or image name 6. Upload the project to the same directory as tomcat, unzip it and run it to achieve deployment illustrate: One container can deploy one project, so isn't it strange? If I deploy three applications on the same server, a front-end UI, a back-end Admin, and a database MySQL, then the back-end needs to manage the front-end data, and their configuration files docker-compose are as follows admain path: /usr/local/docker/tomcat version: '3.1' services: tomcat: restart: always image: tomcat container_name: tomcat ports: -8082:8080 volumes: - /usr/local/docker/tomcat:/usr/local/tomcat/webapps/ROOT environment: TZ: Asia/Shanghai UI: /usr/local/docker/tomcat_ui version: '3.1' services: tomcat: restart: always image: tomcat container_name: tomcatui ports: -8083:8080 volumes: - /usr/local/docker/tomcat_ui:/usr/local/tomcat/webapps/ROOT environment: TZ: Asia/Shanghai~ mysql path: /usr/local/docker/mysql Configuration of docekr-compose version: '3.1' services: db: 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 admin: image: adminer restart: always ports: - 8080:8080 How does the backend manage the front-end data? In fact, it depends on the project you deployed. There is a data connection configuration in the project as follows JDBC jdbc.driverClass=com.mysql.jdbc.Driver jdbc.connectionURL=jdbc:mysql://192.168.206.128:3306/twg?useUnicode=true&characterEncoding=utf-8&useSSL=false jdbc.username=root jdbc.password=123456 # JDBC Pool jdbc.pool.init=1 jdbc.pool.minIdle=3 jdbc.pool.maxActive=20 JDBC Test jdbc.testSql=SELECT 'x' FROM DUAL Then the jdbc.connectionURL=jdbc:mysql://192.168.206.128:3306/twg?useUnicode=true&characterEncoding=utf-8&useSSL=false configured here is the key. In fact, data management is carried out through this IP. This IP is the server IP deployed by MySQL, so the connection configuration of the deployed project points to this IP, so that the background can obtain the data of this database and directly manage the front-end data. Moreover, database visualization interfaces such as Navicat and SQLyog can easily manage the data in the server database using the IP deployed by the database, such as the IP above. If you need to stop a service, you can use docker-compose down in the folder corresponding to the service and in the directory at the same level as docker-compose to stop the service directly. This is the end of this article about the implementation of docker-compose based on MySQL8 deployment project. For more relevant content about docker-compose deployment of MySQL8, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Solution to the problem that the page is blank when opening the page with source file in IE7
>>: Let's talk about the issue of passing parameters to React onClick
An interesting discovery: There is a table with a...
Table of contents 1. Simple to use 2. Use DISTINC...
The origin of the problem The first time I paid a...
Table of contents need Workaround 1. Set tooltip ...
Table of contents Login business process Login fu...
What is a profile? We can use it when we want to ...
In Node.js, a .js file is a complete scope (modul...
Preface This chapter uses basic Linux functions a...
Compared with FTP, SSH-based sftp service has bet...
This article example shares the specific code of ...
Table of contents 1. writable: writable 2. enumer...
1. Introduction Recently, I helped a friend to ma...
In the project, we often encounter the problem of...
effect: The GROUP_CONCAT function can concatenate...
This article describes how to install mysql5.6 us...