docker compose搭建mongodb docker-compose搭建mongodb、mysql的详细过程
abcdefgab 人气:0想了解docker-compose搭建mongodb、mysql的详细过程的相关内容吗,abcdefgab在本文为您仔细讲解docker compose搭建mongodb的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:docker,compose搭建mongodb,docker,compose搭建mysql,下面大家一起来学习吧。
下面看下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: mongocontainer
my.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/
加载全部内容