buildah使用注意事项

buildah 很多细节官方文档没有提到,需要自己踩坑:

1.启用 user_namespace(容器内的uid可以映射成宿主上不一样的uid,安全增强)

echo 10000 > /proc/sys/user/max_user_namespaces  #临时开启

echo "user.max_user_namespaces=10000" >> /etc/sysctl.conf #永久生效

2.我们ci机器的用户是gitlab-runner,所有要配置rootless

官方地址:https://github.com/containers/podman/blob/master/docs/tutorials/rootless_tutorial.md

3. buildah 在运行时需要写一些临时文件以及存储镜像层信息,如果不配置会报权限错误,当然我是最暴力的方式,应该可以通过配置文件的方式去解决,

在开机启动脚本 /etc/rc.local 加入以下信息

chown -R gitlab-runner.gitlab-runner /run/user
chown -R gitlab-runner.gitlab-runner /run/containers

4.内核升级,运行buildah 对内核版本有要求(低版本不支持user namespace特性),最低:3.10.0-1127.el7.x86_64

原文地址:https://www.cnblogs.com/dufeixiang/p/14832459.html