[root@master zookeeper]# ll
total 213916
-rw-r--r-- 1 root root 406 Oct 18 2020 Dockerfile
-rw-r--r-- 1 root root 181365687 Oct 18 2020 jdk-8u77-linux-x64.tar.gz
-rw-r--r-- 1 root root 37676320 Oct 18 2020 zookeeper-3.4.14.tar.gz
从/opt/ChinaskillMall/ 下导入入JDK和Zookeeper
[root@master]# cp -rvf /opt/ChinaskillMall/jdk-8u77-linux-x64.tar.gz zookeeper-3.4.14.tar.gz [放到指定的目录下]
写入Dockerfile文件
[root@master zookeeper]# cat Dockerfile
FROM 192.168.100.10/library/centos:centos7.5.1804 #镜像来源
MAINTAINER Chinaskill #镜像作者
ADD ./jdk-8u77-linux-x64.tar.gz /opt/ #添加jdk文件到(镜像)容器内
ADD ./zookeeper-3.4.14.tar.gz /opt/ #添加zookeper文件到(镜像)容器内
ENV JAVA_HOME=/opt/jdk1.8.0_77 #设置java环境
ENV ZOOKEEPER_HOME=/opt/zookeeper-3.4.14 #设置zookeeper环境
ENV PATH=$JAVA_HOME/bin:$ZOOKEEPER_HOME:/bin:$PATH #添加并执行环境
EXPOSE 2181 #暴露端口
RUN cp $ZOOKEEPER_HOME/conf/zoo_sample.cfg $ZOOKEEPER_HOME/conf/zoo.cfg #拷贝zookeeper文件
CMD $ZOOKEEPER_HOME/bin/zkServer.sh start-foreground #执行命令
docker build -t zookeeper:test .#构建镜像
docker build -t zookeeper:test .
docker images | grep zookeeper #查看镜像ID
docker run -itd -P ac5eb1030cdb #运行ID
docker ps -l #查看最近在运行的容器
docker rm -f 5203b732845a #删除容器