免费资源网 – https://freexyz.cn/
下面看下docker-compose搭建mongodb、mysql的详细方法,内容如下所示:
version: 3 services: mysqldbservice: image: mysql:latest restart: always container_name: mysqlcontainer volumes: – ./data:/var/lib/mysql – ./my.cnf:/etc/mysql/my.cnf – ./init:/docker-entrypoint-initdb.d/ ports: – 3306:3306 #“宿主机端口号:容器内端口号” environment: MYSQL_ROOT_PASSWORD: “” MYSQL_USER: # 创建普通用户 MYSQL_PASSWORD: #普通用户密码 MYSQL_DATABASE: #创建一个库 mongodbservice: # 镜像名称,不写版本号的话默认拉取最近的版本 image: mongo:latest # 端口映射 ports: # 宿主机端口:容器端口 – 27017:27017 # 容器数据挂载,持久化 volumes: # 宿主机目录:容器目录:读写权限 – ./mongo:/data/db:rw – ./configdb:/data/configdb:rw # 设置环境变量 environment: – TZ=Asia/Shanghai # 容器名称 container_name: mongocontainermy.cnf
[mysqld] pid-file = /var/run/mysqld/mysqld.pid socket = /var/run/mysqld/mysqld.sock datadir = /var/lib/mysql secure-file-priv= NULL # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 # Custom config should go here !includedir /etc/mysql/conf.d/
免费资源网 – https://freexyz.cn/
© 版权声明
THE END
暂无评论内容