【docker】pc error: code = 13 desc = invalid header field value "oci runtime error: exec failed 解決方法

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

問題就會解決,可以愉快的進入容器啦!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章