启动容器报错OCI runtime create failed: container_linux.go:367:,可能与错误的方式导入镜像有关

最近被安排迁移开发服务器,肯定要迁移服务器的镜像。导出的镜像因为要网络传输,所以就压缩了一下。命令如下

docker save -o centos73.tar centos-php7312:v1.0
tar -cvzf  centos73.tar.gz centos73.tar 

网络传过来之后用gzip -d 解压(问题出在这)后就用docker load导入 发现报错,

open /var/lib/docker/tmp/docker-import-********/repositories: no such file or directory

然后尝试用docker import ,竟然可以导入,就没有关注。

之后就是用镜象启动容器,然后就报错了

ERROR: for xxx Cannot start service xxx : OCI runtime create failed: container_linux.go:367: starting container process caused: exec: "sh": executable file not found in $PATH: unknown

ERROR: Encountered errors while bringing up the project.

按理说使用save命令导出的镜像要用 load导入才对。

网上有说需要完全解压再重新打包一下。

所以我考虑到可能解压镜像文件的方式有问题。

用tar -xvf 解压了一下centos73.tar。再用load命令导入。这次成功了。问题排查了有一会,所以记录一下。或许能够帮助到网友。

总结:docker save 命令导出的镜像格式是.tar 是打包文件。压缩后带.gz 后缀是压缩文件。需要用tar 来解压。