编写docker-compose.yml
version: '3'
services:
nacos:
image: nacos/nacos-server:latest
container_name: nacos-standalone-mysql
environment:
- "PREFER_HOST_MODE=hostname"
- "MODE=standalone"
- "MYSQL_DATABASE_NUM=1"
- "SPRING_DATASOURCE_PLATFORM=mysql"
- "MYSQL_SERVICE_HOST=外网ip"(数据库外网ip)
- "MYSQL_SERVICE_DB_NAME=nacos"(数据库名称,需要事前先创建好数据库以初始化表,有需要可以留言发送)
- "MYSQL_SERVICE_PORT=3306"(数据库端口)
- "MYSQL_SERVICE_USER=root"(数据库用户名)
- "MYSQL_SERVICE_PASSWORD=pass"(数据库密码)
volumes:
- /usr/local/docker/nacos/standalone-logs/:/home/nacos/logs
- /usr/local/docker/nacos/custom.properties:/home/nacos/init.d/custom.properties
ports:
- 8848:8848(端口)
restart: on-failure