docker下的zookeeper集群环境搭建

1,zookeeper使用docker的官方镜像

2,编写docker-compose文件

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

3,编写dubbo_admin的Dockerfile

#dubbo_admin专用dockerfile

FROM      centos:7.2.1511
MAINTAINER zzli

ENV REFRESHED_AT 2017-12-19

ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

ADD jdk-8u101-linux-x64.gz /usr/local/
ENV JAVA_HOME /usr/local/jdk1.8.0_101
ENV PATH $JAVA_HOME/bin:$PATH
ENV CLASSPATH .:$JAVA_HOME/lib
ADD apache-tomcat-8.0.36.tar.gz /usr/local/
RUN mv /usr/local/apache-tomcat-8.0.36 /usr/local/tomcat/
RUn chmod +X /usr/local/tomcat/bin/*.sh



#COPY dubbo-admin-2.5.3.war /usr/local/tomcat/webapps/
EXPOSE 8080

ENTRYPOINT /usr/local/tomcat/bin/startup.sh && /bin/bash

提交镜像:
docker build . -t phj/dubbo_admin

4,启动docker命令如下:

docker-compose up -d
docker run -idt --name dubbo_admin -v /data/dubbo_admin/:/usr/local/tomcat/webapps/ -p 8088:8080 phj/tomcat:0.1 /bin/bash

你可能感兴趣的:(docker下的zookeeper集群环境搭建)