Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of building docker in mysql

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the method of building docker in mysql, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

1. Take a look at the directory structure before building it.

Create the corresponding directory according to the directory structure above

two。 Create a profile

Create a my.cnf file in the config directory

My.cnf

[mysqld] character-set-server=utf8mb4default-time-zone='+8:00'innodb_rollback_on_timeout='ON'max_connections=500innodb_lock_wait_timeout=500

Create an .env file in the outer directory of mysql

.env

MYSQL_ROOT_PASSWORD=root

MYSQL_ROOT_HOST=%

MYSQL_DIR=./mysql

Create a docker compose file

Docker-compose.yaml

Version:'3'

Services:

Mysql-db:

Container_name: mysql-docker # specifies the name of the container

Image: mysql: 8.0 # specify image and version

Ports:

-"3306 purl 3306"

Environment:

MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}

MYSQL_ROOT_HOST: ${MYSQL_ROOT_HOST}

Volumes:

-"${MYSQL_DIR} / data:/var/lib/mysql" # Mount the data directory

-"${MYSQL_DIR} / config:/etc/mysql/conf.d" # Mount the configuration file directory

3. test

Start: docker-compose up-d

Viewing: docker ps

15117a33fc98 mysql:8.0 "docker-entrypoint.s..." 24 minutes ago Up 23 minutes 0.0.0.0 3306/tcp 3306-> 33060/tcp mysql-docker

Test:

1. View ip

Docker network ls

Docker network inspect xxx-network-id

two。 Link

Thank you for reading this article carefully. I hope the article "how to build docker in mysql" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report