一、安装docker
yum install -y docker
二、启动docker镜像
sudo service docker start
三、查找zookeeper镜像
sudo docker search zookeeper
四、下载zookeeper镜像
sudo docker pull docker.io/zookeeper
五、下载完后可检查镜像
sudo docker images
六、创建 /usr/local/docker/zookeeper/docker.compose.yml,并给文件添加如下内容:
version: '2'
services:
zoo1:
image: zookeeper
restart: always
container_name: zoo1
ports:
- "2181:2181"
environment:
ZOO_MY_ID: 1
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo2:
image: zookeeper
restart: always
container_name: zoo2
ports:
- "2182:2181"
environment:
ZOO_MY_ID: 2
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
zoo3:
image: zookeeper
restart: always
container_name: zoo3
ports:
- "2183:2181"
environment:
ZOO_MY_ID: 3
ZOO_SERVERS: server.1=zoo1:2888:3888 server.2=zoo2:2888:3888 server.3=zoo3:2888:3888
七、启动docker
sudo systemctl start docker
八、启动服务器集群
docker-compose up -d
九、查看docker ps