2

alphine镜像的使用技巧

 2 years ago
source link: https://zhangrr.github.io/posts/20211104-alphine_usage/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

用 alphine 镜像的一些常用技巧:

会随时增加:

一、修改源,用国外的源非常慢,替换成国内的中科大源

sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories

二、更新apk库

apk update

三、安装软件

#安装telnet
apk add busybox-extras

#安装curl
apk add curl

#安装时间组件
apk add tzdata

#更新并且安装软件
apk add --update tzdata

四、进入容器一步执行换源、更新、安装

sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && apk update && apk add curl && apk add busybox-extras

五、解决缺少glibc库的问题

如果不ln会报错,原因是缺少glibc库!!!解决方法如下:

RUN mkdir /lib64 && \  
    ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2  

六、一些调试的CMD

CMD ["/bin/bash", "-c", "while true; do echo hi; sleep 10; done"]

kubectl run curlpod --image=radial/busyboxplus:curl --command -- /bin/sh -c "while true; do echo hi; sleep 10; done"

七、pod的等待技巧

这儿里启动正式的pod之前,先临时起了两个容器等待其他服务的完成

  containers: 
  - name: myapp-container 
    image: busybox 
    command: ['sh', '-c', 'echo The app is running! && sleep 3600'] 
  initContainers: 
  - name: init-myservice 
    image: busybox 
    command: ['sh', '-c', 'until nslookup myservice; do echo waiting for myservice; sleep 2; done;'] 
  - name: init-mydb 
    image: busybox 
    command: ['sh', '-c', 'until nslookup mydb; do echo waiting for mydb; sleep 2; done;'] 

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK