目录

十月末-solo博客

talk less,code more.

数据库cli工具docker镜像

经常要在容器环境中查看众多数据库的数据或验证服务,基于 alpine 打包了一个 db cli 工具镜像。

注:工具并不涉及数据库管理。

alpine 软件源已替换为了清华园,时区设置为上海,包含了 nmap 和 curl 网络工具和 mycli、redis-cli、mongocli、etcdcli、和 plumber 等数据库 cli 工具。docker 镜像已上传至腾讯镜像源 ccr.ccs.tencentyun.com/bingoct/apline-db-tools:v1.0.0

FROM alpine:3.16 as build
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && apk update && apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/shanghai" >>/etc/timezone
# etcd
RUN wget -O /tmp/etcd-v3.5.0-linux-amd64.tar.gz https://github.com/etcd-io/etcd/releases/download/v3.5.0/etcd-v3.5.0-linux-amd64.tar.gz
RUN tar xf /tmp/etcd-v3.5.0-linux-amd64.tar.gz -C /tmp
# zkcli
RUN wget -O /tmp/zkcli-0.4.0-linux-amd64.tar.gz https://github.com/let-us-go/zkcli/releases/download/v0.4.0/zkcli-0.4.0-linux-amd64.tar.gz
RUN tar xf /tmp/zkcli-0.4.0-linux-amd64.tar.gz -C /tmp
# mongocli
RUN wget -O /tmp/mongocli_1.25.0_linux_x86_64.tar.gz https://fastdl.mongodb.org/mongocli/mongocli_1.25.0_linux_x86_64.tar.gz
RUN tar xf /tmp/mongocli_1.25.0_linux_x86_64.tar.gz -C /tmp
# plumber
RUN wget -O /tmp/plumber https://github.com/batchcorp/plumber/releases/latest/download/plumber-linux && chmod +x /tmp/plumber


FROM alpine:3.16
# change apk source and set time-zone
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && apk update && apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/shanghai" >>/etc/timezone
# db-tool
RUN apk add nmap curl mycli redis
COPY --from=build /tmp/mongocli_1.25.0_linux_x86_64/bin/mongocli /usr/local/bin/
COPY --from=build /tmp/etcd-v3.5.0-linux-amd64/etcdctl /usr/local/bin/
COPY --from=build /tmp/zkcli-0.4.0-linux-amd64/zkcli /usr/local/bin/
COPY --from=build /tmp/plumber /usr/local/bin/ /usr/local/bin/

使用

kubectl run -ti alpine-db-tool --image=ccr.ccs.tencentyun.com/bingoct/apline-db-tools:v1.0.0 -- sh
# or docker
docker run -ti  --name alpine-db-tool ccr.ccs.tencentyun.com/bingoct/apline-db-tools:v1.0.0 sh

工具官方文档:

todo:

  • plumber 和 mycli 太大了,导致最终镜像有 196.59MB。
  • 构建 web ui client(坑太大)

标题:数据库cli工具docker镜像
作者:bingoct
地址:https://blog.bingoct.top/articles/2022/07/27/1658888042786.html
Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.