docker docker-compose安装查看上一篇文章
1.新建目录并创建docker-compose.yaml 文件
文件内容
services: mysql: image: mysql:8.2.0 container_name: mysql environment: MYSQL_ROOT_PASSWORD: 1qaz@WSX MYSQL_DATABASE: nacos MYSQL_USER: nacos_user MYSQL_PASSWORD: 1qaz@WSX ports: - "3306:3306" volumes: - /mysql:/var/lib/mysql restart: always nacos: image: nacos/nacos-server:v2.4.2 container_name: nacos depends_on: - mysql environment: MODE: standalone SPRING_DATASOURCE_PLATFORM: mysql MYSQL_SERVICE_HOST: mysql MYSQL_SERVICE_DB_NAME: nacos MYSQL_SERVICE_PORT: 3306 MYSQL_SERVICE_USER: root MYSQL_SERVICE_PASSWORD: 1qaz@WSX MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true ports: - "8848:8848" - "9848:9848" volumes: - /nacos/conf:/home/nacos/conf - /nacos/logs:/home/nacos/logs restart: always redis: image: redis:alpine container_name: redis ports: - "6379:6379" command: redis-server --requirepass 1qaz@WSX volumes: - /redis/data:/data restart: always
2.启动服务
[root@localhost compose]# docker-compose up -d
3.查看服务状态
[root@localhost compose]# docker-compose ps
4.停止服务
[root@localhost compose]# docker-compose down
5.使用数据库工具或服务连接使用mysql redis服务
redis连接地址为docker安装机器ip,端口6379,,密码为
1qaz@WSX
使用dbeaver软件连接mysql数据库,连接地址为docker安装机器ip
,端口为3306
,用户名为root
,密码为1qaz@WSX
,数据库为nacos
6.nacos使用前在mysql中初始化数据
nacos访问http://docker安装机器ip:8848/nacos
, 即可使用nacos服务,用户名和密码:nacos/nacos。
标签:compose,mysql,redis,nacos,MYSQL,docker From: https://www.cnblogs.com/kenmeon/p/18467682