docker swarm 集群debian基础镜像

docker

#场景

之前服务都是基于 rust和golang 所以一直使用公用镜像。但是在使用对象储存的时候发现缺少ssl支持。
不得不

#准备文件

  • sources.list (服务器上 没科学工具)
  • zsh 配置文件(偶尔需要在容器内部操作所以还是加上)

#sourece.list

plaintext
deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src http://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

deb http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src http://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

#zsh 配置文件

https://github.com/joyanhui/oh-my-zsh

plaintext
rm -rf .oh-my-zsh yhZsh.zip .zshrc
curl  -L -e  '; auto' -o yhZsh.zip https://mirror.ghproxy.com/https://github.com/joyanhui/oh-my-zsh/archive/refs/heads/main.zip
unzip yhZsh.zip 
mv oh-my-zsh-main/.oh-my-zsh  . && cp oh-my-zsh-main/.zshrc .
rm -rf yhZsh.zip oh-my-zsh-main

适当删除一些没用的插件和主题

#Dockerfile

Dockerfile
FROM debian:stable-20231120-slim
MAINTAINER author "[email protected]"
ADD sources.list /etc/apt/
ADD .zshrc /root/
COPY .oh-my-zsh /root/.oh-my-zsh
#ADD rclone /usr/bin/
RUN rm -rf /etc/apt/sources.list.d/debian.sources && \
    apt-get update && apt-get install -y apt-transport-https ca-certificates gnupg lsb-release && \
    apt-get install -y psmisc wget curl unzip zip fuse zsh ntp iftop openssh-server && \
    apt autoremove && apt-get clean && apt-get autoclean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
WORKDIR /root
EXPOSE 22
CMD ["/usr/sbin/sshd","-D"]

#容器服务

因为更新较少,所以使用阿里云的

sh
sudo docker login --username=<用户名>  registry.cn-shanghai.aliyuncs.com

nowTime=$(date "+%Y%m%d%H%M%S")
sudo docker build -t  registry.cn-shanghai.aliyuncs.com/fish/debian:base-"${nowTime}" .

sudo docker tag registry.cn-shanghai.aliyuncs.com/fish/debian:base-"${nowTime}"  registry.cn-shanghai.aliyuncs.com/fish/debian:base-latest



sudo docker push registry.cn-shanghai.aliyuncs.com/fish/debian:base-"${nowTime}"
sudo docker push registry.cn-shanghai.aliyuncs.com/fish/debian:base-latest

#swarm集群部署

在集群上分别登陆
然后

sh
docker pull registry.cn-shanghai.aliyuncs.com/fish/debian:latest

评论