1、拉取镜像
sudo docker pull daocloud.io/daocloud/zookeeper:3.4.10
2、查看
sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/hello-world latest e38bc07ac18e 9 days ago 1.85 kB
daocloud.io/daocloud/zookeeper 3.4.10 f2249a75c5d0 7 months ago 143 MB
daocloud.io/library/mysql 5.7.4 aa5364eb3d85 3 years ago 252 MB
3 运行容器,设置了挂载卷,设置了3个暴露端口,
sudo docker run -it --volumes-from mysql-data --name zookeeper -p 2181:2181 -p 2888:2888 -p 3888:3888 --restart always -d daocloud.io/daocloud/zookeeper:3.4.10
4、进入容器,并配置zookeeper
sudo docker exec -it zookeeper /bin/bash
5 看下目录结构
bash-4.3# cd /
bash-4.3# ls
bin datalog etc media proc sbin tmp zookeeper-3.4.10
conf dev home mnt root srv usr
data docker-entrypoint.sh lib opt run sys var
注意,zookeeper的安装目录在 /zookeeper-3.4.10,而配置文件在/conf
bash-4.3# cd conf/
bash-4.3# ls
configuration.xsl log4j.properties zoo.cfg zoo_sample.cfg
bash-4.3# vi zoo.cfg
clientPort=2181
dataDir=/data
dataLogDir=/datalog
tickTime=2000
initLimit=5
syncLimit=2
maxClientCnxns=60
可以看到,它已经把data目录配置好了,就在根目录下的data文件夹下。我们直接拿来用就行了
网友评论