记录一下
version: '2.1'
services:
mysql:
image: smartbi-mysqlc
ports:
- "3307:3306"
volumes:
- I:\data\smartbi:/var/lib/mysql/smartbi
hostname: mysql
mem_limit: 1000000000
memswap_limit: 2000000000
cpuset: 0,1
command: /usr/bin/mysqld_safe
tomcat:
image: smartbi-tomcatc-tp
ports:
- "8081:8080"
- "8082:8082"
volumes:
- I:\smartbic:/tomcat/webapps
- I:\smartbi-config.xml:/smartbi-config.xml
- I:\Smartbi-License.xml:/Smartbi-License.xml
hostname: tomcat
command: tail -f /tomcat/conf/server.xml
infobright:
image: smartbi-infobright
ports:
- "5029:5029"
hostname: infobright
command: tail -f anaconda-post.log
gp:
image: smartbi-gp-ccpg
ports:
- "5433:5432"
- "28081:28080"
- "8090:80"
hostname: gp
command: tail -f /home/gpadmin/all_segs
mdw:
image: smartbi-gpnc
hostname: mdw
networks:
gp_bridge:
ipv4_address: 192.168.1.10
extra_hosts:
- "seg: 192.168.1.11"
ports:
- "5432:5432"
- "28080:28080"
volumes:
- I:\start.sh:/home/gpadmin/startup.sh
- I:\all_segs:/home/gpadmin/all_segs
- I:\all_hosts:/home/gpadmin/all_hosts
#command: /usr/sbin/sshd -D && /usr/sbin/ntpd -d
seg:
image: smartbi-gpnc
hostname: seg
networks:
gp_bridge:
ipv4_address: 192.168.1.11
extra_hosts:
- "mdw: 192.168.1.10"
#command: /usr/sbin/sshd -D && /usr/sbin/ntpd -d
networks:
gp_bridge:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.1.0/24
gateway: 192.168.1.1
version: '2.1'
services:
mysql:
image: smartbi-mysqlc
ports:
- "3307:3306"
volumes:
- I:\data\smartbi:/var/lib/mysql/smartbi
hostname: mysql
mem_limit: 1000000000
memswap_limit: 2000000000
cpuset: 0,1
command: /usr/bin/mysqld_safe
tomcat:
image: smartbi-tomcatc-tp
ports:
- "8081:8080"
- "8082:8082"
volumes:
- I:\smartbic:/tomcat/webapps
- I:\smartbi-config.xml:/smartbi-config.xml
- I:\Smartbi-License.xml:/Smartbi-License.xml
hostname: tomcat
command: tail -f /tomcat/conf/server.xml
infobright:
image: smartbi-infobright
ports:
- "5029:5029"
hostname: infobright
command: tail -f anaconda-post.log
gp:
image: smartbi-gp-ccpg
ports:
- "5433:5432"
- "28081:28080"
- "8090:80"
hostname: gp
command: tail -f /home/gpadmin/all_segs
mdw:
image: smartbi-gpnc
hostname: mdw
networks:
gp_bridge:
ipv4_address: 192.168.1.10
extra_hosts:
- "seg: 192.168.1.11"
ports:
- "5432:5432"
- "28080:28080"
volumes:
- I:\start.sh:/home/gpadmin/startup.sh
- I:\all_segs:/home/gpadmin/all_segs
- I:\all_hosts:/home/gpadmin/all_hosts
#command: /usr/sbin/sshd -D && /usr/sbin/ntpd -d
seg:
image: smartbi-gpnc
hostname: seg
networks:
gp_bridge:
ipv4_address: 192.168.1.11
extra_hosts:
- "mdw: 192.168.1.10"
#command: /usr/sbin/sshd -D && /usr/sbin/ntpd -d
networks:
gp_bridge:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.1.0/24
gateway: 192.168.1.1
其中主要用到的:
image: 就是你这个容器要使用的镜像
image: smartbi-mysqlc
ports: 你需要映射的端口
ports:
- "3307:3306"
volumes: 需要挂载的文件
volumes:
- I:\data\smartbi:/var/lib/mysql/smartbi
hostname: 主机名
hostname: mysql
command: 就是容器启动时会执行的命令,但是只能执行一个command 并且是最后一个command命令。
command: /usr/bin/mysqld_safe
networks : services中的则是创建的网络
gp_bridge:
driver: bridge
ipam:
driver: default
config:
- subnet: 192.168.1.0/24 网段
gateway: 192.168.1.1 网关
容器里的则是该容器的一些信息
ipv4_address: 192.168.1.10 容器ip
extra_hosts : 相当于linux中/etc/hosts文件
extra_hosts:
- "seg: 192.168.1.11"
mem_limit:
memswap_limit : 限制内存
cpuset : 限制CPU
详细的可以查看https://docs.docker.com/compose/compose-file/#linklocalips
使用docker-compose命令 的时候,你所在的目录要是compose文件所在的目录下