docker pull wdkang/kafka-console-ui
docker images
由于Docker内不会对数据进行持久化 所以这里推荐将数据目录映射到实体机中
详见 2.数据持久
docker run -d -p 7766:7766 wdkang/kafka-console-ui
docker ps -a
docker logs -f ${containerId}
http://localhost:7766
推荐对数据进行持久化
mkdir -p /home/kafka-console-ui/data /home/kafka-console-ui/log
cd /home/kafka-console-ui
docker run -d -p 7766:7766 -v $PWD/data:/app/data -v $PWD/log:/app/log wdkang/kafka-console-ui
前置需求
(可根据自身情况修改Dockerfile)
解压后 将Dockerfile放入文件夹的根目录
Dockerfile
# jdk
FROM openjdk:8-jdk-alpine
# label
LABEL by="https://github.com/xxd763795151/kafka-console-ui"
# root
RUN mkdir -p /app && cd /app
WORKDIR /app
# config log data
RUN mkdir -p /app/config && mkdir -p /app/log && mkdir -p /app/data && mkdir -p /app/lib
# add file
ADD ./lib/kafka-console-ui.jar /app/lib
ADD ./config /app/config
# port
EXPOSE 7766
# start server
CMD java -jar -Xmx512m -Xms512m -Xmn256m -Xss256k /app/lib/kafka-console-ui.jar --spring.config.location="/app/config/" --logging.home="/app/log" --data.dir="/app/data"
进行打包
在文件夹根目录下
(注意末尾有个点)
docker build -t ${your_docker_hub_addr} .
docker push ${your_docker_hub_addr}
# docker-compose 编排
version: '3'
services:
# 服务名
kafka-console-ui:
# 容器名
container_name: "kafka-console-ui"
# 端口
ports:
- "7766:7766"
# 持久化
volumes:
- ./data:/app/data
- ./log:/app/log
# 防止读写文件有问题
privileged: true
user: root
# 镜像地址
image: "wdkang/kafka-console-ui"
docker-compose pull kafka-console-ui
docker-compose up --detach --build kafka-console-ui
docker-compose ps -a
docker-compose down