podman部署到运行的容器里面,实现类似Docker in docker

解决在容器里面运行Podman 错误:

could not get runtime: kernel does not support overlay fs: 'overlay' is not supported over xfs at "/var/lib/containers/storage/overlay": backing file system is unsupported for this graph driver

podman run --privileged -it --rm -v /var/run/containers/storage:/var/run/containers/storage -v /var/lib/containers/storage:/var/lib/containers/storage  centos:latest

这样运行podman info 没有问题

推荐的一种方式

[storage]

driver = "overlay"

[storage.options]

mount_program = "/usr/bin/fuse-overlayfs"

sed -i 's/#mount_program/mount_program/g' /etc/containers/storage.conf

podman run --privileged -it --rm centos:latest

dnf install podman -y 

sed -i 's/#mount_program/mount_program/g' /etc/containers/storage.conf

podman info 

但是还有一个问题是在podman build 的时候发生的错误

Error: OCI runtime error: systemd cgroup flag passed, but systemd support for managing cgroups is not available

解决方案:

1. 容器运行时知道 cgroup_manager="cgroupfs"

podman  --cgroup-manager  run --privileged -it --rm -v /var/run/containers/storage:/var/run/containers/storage -v /var/lib/containers/storage:/var/lib/containers/storage  centos:latest

2.设置 containers.conf
vim /etc/containers/containers.conf

[engine]
cgroup_manager="cgroupfs"

第一种方式podman,没有改变

podman info |egrep cgroupManager
cgroupManager: systemd

本人测试第二种方式没问题问题(推荐方式)

podman info |egrep cgroupManager
cgroupManager: cgroupfs

在K8S 部署的时候需要指定的配置文件

 

podman push nginx 镜像的时候发生下面的报错

原因是harbor版本太老,不支持新的镜像格式

默认podman build 是OCI 

podman build --help |egrep format

--format format format of the built image's manifest and metadata. Use BUILDAH_FORMAT environment variable to override. (default "oci")

 

 

解决方案:

https://bugzilla.redhat.com/show_bug.cgi?id=1833008

  --format docker 

podman build -t nginx:test   --format docker -f Dockerfile-nginx .

posted @ 2021-05-29 20:04  屌丝的IT  阅读(1687)  评论(0编辑  收藏  举报