Docer Compose 配置
创建外部网络
如果没有外部网络,需要运行以下命令创建:
1 2 3 4 5
| docker network ls
docker network create --driver bridge --subnet 10.10.13.0/24 --gateway 10.10.13.1 docker_compose_net
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| version: "3"
networks: default: external: name: docker_compose_net
services: agile_config_admin: image: "kklldog/agile_config:v-1.6.14" container_name: agile-admin restart: unless-stopped ports: - "15000:5000" volumes: - /etc/localtime:/etc/localtime environment: - adminConsole=true env_file: - ./var.env agile_config_node1: image: "kklldog/agile_config:v-1.6.14" container_name: agile-node1 restart: unless-stopped ports: - "15001:5000" volumes: - /etc/localtime:/etc/localtime env_file: - ./var.env depends_on: - agile_config_admin agile_config_node2: image: "kklldog/agile_config:v-1.6.14" container_name: agile-node2 restart: unless-stopped ports: - "15002:5000" volumes: - /etc/localtime:/etc/localtime env_file: - ./var.env depends_on: - agile_config_admin
|
注意:
- 1,docker-compose 中
$
会进行插值操作,如果连接串中有 $
符号,需要引入外部环境变量文件。
- 2,注意数据库链接服务器地址: 单反斜杠(不推荐),命名实例推荐端口号方式。
与 docker-compose.yml
同目录下:
var.env
内容
1 2 3 4
| TZ=Asia/Shanghai cluster=true db__provider=sqlserver db__provider= Encrypt=True;TrustServerCertificate=True;Persist Security Info=False; User ID=ConfigServer; Password=RlDjqOpF$; Initial Catalog=ConfigCenter; Server=10.10.0.36,1435;
|
目录结构如下:
1 2 3
| /lims/agile_config ├── docker-compose.yml └── var.env
|
Docker&Docker Compose 命令
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| # 启动 docker-compose up -d
# 移除 docker-compose down -v
# 查看容器信息 docker inspect agile_config-agile_config_admin-1
# 重启 docker-compose restart
# 查看容器内文件 docker exec lims-server tail -n +0 AdminNETConfig.json
|