docker 报错,无法进入容器
- rpc error: code = 13 desc = invalid header field value “oci runtime error: exec failed: container_linux.go:247: starting container process caused “process_linux.go:75: starting setns process caused \“fork/exec /proc/self/exe: no such file or directory\””\n”
- 如果大家在使用docker的过程中遇到以上问题,不用慌,可以使用这种方法解决,【【【看清错误错误代码,别白忙活一场】】】
在任意位置新建一个shell脚本 fix-docker.sh
#!/bin/bash
# author: phpor
#
LIBCONTAINERD_DIR=/var/run/docker/libcontainerd
function main() {
local pidOfCotainerd=$(pidof docker-containerd-current)
local mountinfo=$(< /proc/$pidOfCotainerd/mountinfo)
for config in $LIBCONTAINERD_DIR/*/config.json;do
local cid=$(awk -F'/' '{print $6}' <<<$config)
local rootpath=$(jq -r .root.path $config|sed 's/\/rootfs$//')
grep "$rootpath" <<<$mountinfo >/dev/null
if [[ $? -eq 0 ]]; then
echo $cid $rootpath OK
else
echo $cid $rootpath Should repair
local device=/dev/mapper/$(docker inspect $cid|jq -r .[0].GraphDriver.Data.DeviceName)
nsenter -m -p -t $pidOfCotainerd mount -t xfs -o rw,nouuid,attr2,inode64,sunit=512,swidth=1024,noquota $device $rootpath
fi
done
}
main
执行脚本:
/bin/bash fix-docker.sh
问题就会解决,可以愉快的进入容器啦!