创建镜像
进入应用目录(存在 Dockerfile 文件):
1
| docker build -t lims:0.0.2 .
|
测试
1 2 3 4 5 6 7 8 9
| # –rm :退出时,删除容器 docker run --name lims-server -e TZ=Asia/Shanghai -p 80:80 -d lims:0.0.2
# 多行命令 docker run \ --name lims-server \ -e TZ=Asia/Shanghai \ -p 80:80 \ -d lims:0.0.2
|
Docker Compose 编排
目录结构:
1 2 3
| . ├── docker-compose.yml └── var.env
|
docker-compose.yml
文件:
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
| version: "3" services: lims_node1: image: lims:0.0.2 restart: always container_name: lims_node1 ports: - "5000:80" networks: - net0 volumes: - /etc/localtime:/etc/localtime env_file: - ./var.env lims_node2: image: lims:0.0.2 restart: always container_name: lims_node2 ports: - "5001:80" networks: - net0 volumes: - /etc/localtime:/etc/localtime env_file: - ./var.env lims_node3: image: lims:0.0.2 restart: always container_name: lims_node3 ports: - "5002:80" networks: - net0 volumes: - /etc/localtime:/etc/localtime env_file: - ./var.env networks: net0:
|
var.env
文件:
1 2 3
| TZ=Asia/Shanghai AgileConfig__secret=ulxnjRq5jSSs AgileConfig__env=TEST
|
命令
1 2 3 4 5 6 7 8 9 10 11
| # 启动 docker compose up -d
# 移除 docker-compose down -v
# 重启 docker-compose restart
# 查看运行的容器 docker ps
|