Docker hello-world给出以下错误:容器/ hello:无此类文件或目录“:未知

时间:2019-03-20 21:51:38

标签: docker containers centos7

我是Docker的新手,请尝试了解它的工作原理。我将docker安装到virtualbox centos 7实例。该服务正常运行,但是当我运行hello-world映像时,出现以下错误。

 [root@localhost ~]# docker run hello-world
    docker: Error response from daemon: OCI runtime create failed: 
container_linux.go:344: starting container process caused "exec: \"/hello\":
stat /hello: no such file or directory": unknown.

我尝试了$ docker system prune,但无法再次使用。这是所有命令行历史记录,包括系统信息和泊坞窗信息。

[root@localhost ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

[root@localhost ~]# docker --version
Docker version 18.09.3, build 774a1f4
[root@localhost ~]# docker run hello-world
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"/hello\": stat /hello: no such file or directory": unknown.

[root@localhost ~]# docker system prune
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all dangling build cache
Are you sure you want to continue? [y/N] y
Deleted Containers:
ace04702bb0e2a1997dc35a0a21c7ca49a395809e5d1da98ddc99ee16544dcc4
e70f5999470577d0eca655643b7ba2ce41ee99495bb257d8ca5f956c26a7079b
82f65c36f76cf2cbf6297a514865d45524bf3cb4472be5e5da72c632cd535a3b

Total reclaimed space: 0B
[root@localhost ~]# docker run hello-world
docker: Error response from daemon: OCI runtime create failed: container_linux.go:344: starting container process caused "exec: \"/hello\": stat /hello: no such file or directory": unknown.
[root@localhost ~]# docker info
Containers: 1
 Running: 0
 Paused: 0
 Stopped: 1
Images: 1
Server Version: 18.09.3
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: e6b3f5632f50dbc4e9cb6288d911bf4f5e95b18e
runc version: 6635b4f0c6af3810594d2770f662f34ddc15b40d
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 3.701GiB
Name: localhost.localdomain
ID: R2XU:6ZAF:2UZO:QBUR:GGWW:GFIG:DHVF:5DZG:DPG2:GIKV:3GE5:NLS2
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

2 个答案:

答案 0 :(得分:1)

这是由于CentOS的旧版本引起的。 选中https://github.com/moby/moby/issues/35906 请将您的CentOS升级到7.4。

答案 1 :(得分:0)

阅读了一些文档后,我们确认该问题不是来自docker而是由 selinux 配置引起的。它建议 #sestatus当前模式应该允许,但在我的情况下却是强制执行。我认为这使所有错误停止过程而不是日志记录。所以

#setenforce 0  
#docker system prune -a 

有效!

感谢您在此问题上的所有帮助。