标签:启动 http ges code dock docker 集群 env 查看
新建文件 docker-compose.yml
version: ‘2‘ services: zookeeper1: image: zookeeper container_name: zk1.cloud ports: - "2181:2181" environment: - SERVER_ID=1 - ADDITIONAL_ZOOKEEPER_1=server.1=0.0.0.0:2888:3888 - ADDITIONAL_ZOOKEEPER_2=server.2=zk2.cloud:2888:3888 - ADDITIONAL_ZOOKEEPER_3=server.3=zk3.cloud:2888:3888 zookeeper2: image: zookeeper container_name: zk2.cloud ports: - "2182:2181" environment: - SERVER_ID=2 - ADDITIONAL_ZOOKEEPER_1=server.1=zk1.cloud:2888:3888 - ADDITIONAL_ZOOKEEPER_2=server.2=0.0.0.0:2888:3888 - ADDITIONAL_ZOOKEEPER_3=server.3=zk3.cloud:2888:3888 zookeeper3: image: zookeeper container_name: zk3.cloud ports: - "2183:2181" environment: - SERVER_ID=3 - ADDITIONAL_ZOOKEEPER_1=server.1=zk1.cloud:2888:3888 - ADDITIONAL_ZOOKEEPER_2=server.2=zk2.cloud:2888:3888 - ADDITIONAL_ZOOKEEPER_3=server.3=0.0.0.0:2888:3888
启动集群
docker-compose up
后台启动
docker-compose -d up
查看启动状态
docker-compose ps
还可以在启动时直接指定
docker run -d -p 2181:2181 --name zk1 --link zk2:zknode2 --link zk3:zknode3 --net foo -e SERVER_ID=1 -e ADDITIONAL_ZOOKEEPER_1=server.1=0.0.0.0:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=zknode2:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=zknode3:2888:3888 zookeeper
docker run -d -p 2182:2181 --name zk2 --link zk1:zknode1 --link zk3:zknode3 --net foo -e SERVER_ID=1 -e ADDITIONAL_ZOOKEEPER_1=server.1=zknode1:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=0.0.0.0:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=zknode3:2888:3888 zookeeper
docker run -d -p 2183:2181 --name zk3 --link zk2:zknode2 --link zk1:zknode1 --net foo -e SERVER_ID=1 -e ADDITIONAL_ZOOKEEPER_1=server.1=zknode1:2888:3888 -e ADDITIONAL_ZOOKEEPER_2=server.2=zknode2:2888:3888 -e ADDITIONAL_ZOOKEEPER_3=server.3=0.0.0.0:2888:3888 zookeeper
标签:启动 http ges code dock docker 集群 env 查看
原文地址:http://www.cnblogs.com/wenbronk/p/6438492.html