赞
踩
(一)编写docker-compose.yml
官网地址:https://docs.docker.com/compose/compose-file/
- version: '3'
- services:
- back:
- image: backService:1.0
- container_name: back
- environment:
- - name=tom
- - DB_PATH=jdbc:sqlite:/data/ns.db
- restart: always
- privileged: true
- ports:
- - "9000:9000"
- networks:
- - "net"
- volumes:
- - "/root/k3s.kube.config:/k3s.kube.config"
- - "/root/data:/data"
- - "/etc/network/interfaces:/etc/network/interfaces"
- front:
- image: front:1.0
- container_name: front
- restart: always
- ports:
- - "10087:80"
- networks:
- - "net"
- volumes:
- - "/root/nginx.conf:/etc/nginx/nginx.conf"
- networks:
- net:
- driver: bridge
version:指定 docker-compose.yml 文件的写法格式
services:多个容器集合environment:环境变量配置,可以用数组或字典两种方式
- environment:
- RACK_ENV: "development"
- SHOW: "ture"
- -------------------------
- environment:
- - RACK_ENV="development"
- - SHOW="ture"
image:指定服务所使用的镜像
- version: '2'
- services:
- redis:
- image: redis:alpine
expose:定义容器用到的端口(一般用来标识镜像使用的端口,方便用ports映射)
- expose:
- - "3000"
- - "8000"
ports:定义宿主机端口和容器端口的映射,可使用宿主机IP+宿主机端口进行访问**宿主机端口****
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。