为什么Docker运行失败? exec用户进程导致“没有这样的文件或目录”

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了为什么Docker运行失败? exec用户进程导致“没有这样的文件或目录”相关的知识,希望对你有一定的参考价值。

我正在尝试使用go microservices重现群集群。编写原始代码的人在Mac上工作,我在Ubuntu 18.04上。

我设法建立了图像,但是当我去的时候

docker run --rm someprefix/accountservice

我有严重的问题

standard_init_linux.go:207: exec user process caused "no such file or directory"

Docker检查

docker inspect someprefix/accountservice
[
    {
        "Id": "sha256:a5e37628d346dba85c07933c0d564d097090e23e3fc86e27d75c2a1a2996598e",
        "RepoTags": [
            "someprefix/accountservice:latest"
        ],
        "RepoDigests": [],
        "Parent": "sha256:9120fa959fd47ffeb5275f4a30a97508b90279e80fccbce238c56d80048abebe",
        "Comment": "",
        "Created": "2019-04-30T18:06:08.292837947Z",
        "Container": "ea592f14dd2969078725ca8180335a1844a90270415256bc9466d526f35fc1a6",
        "ContainerConfig": {
            "Hostname": "536a453ae03e",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "6767/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/sh",
                "-c",
                "#(nop) ",
                "ENTRYPOINT ["./accountservice-linux-amd64"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:9120fa959fd47ffeb5275f4a30a97508b90279e80fccbce238c56d80048abebe",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "./accountservice-linux-amd64"
            ],
            "OnBuild": [],
            "Labels": {}
        },
        "DockerVersion": "18.09.5",
        "Author": "",
        "Config": {
            "Hostname": "536a453ae03e",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "6767/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": null,
            "ArgsEscaped": true,
            "Image": "sha256:9120fa959fd47ffeb5275f4a30a97508b90279e80fccbce238c56d80048abebe",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": [
                "./accountservice-linux-amd64"
            ],
            "OnBuild": [],
            "Labels": {}
        },
        "Architecture": "amd64",
        "Os": "linux",
        "Size": 13093818,
        "VirtualSize": 13093818,
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/a3601e0c28ae2733092fff04b223561787158d743e0038e889af5f978bd03cf2/diff:/var/lib/docker/overlay2/2ea56a1556aac38a84a911dbad39b82d2cd060ceb21fc8e01619c382945a045f/diff",
                "MergedDir": "/var/lib/docker/overlay2/cb37e949bab85bf65be5ef6a5b6db6f7fefc12115825f7e6a458b8b45b697d30/merged",
                "UpperDir": "/var/lib/docker/overlay2/cb37e949bab85bf65be5ef6a5b6db6f7fefc12115825f7e6a458b8b45b697d30/diff",
                "WorkDir": "/var/lib/docker/overlay2/cb37e949bab85bf65be5ef6a5b6db6f7fefc12115825f7e6a458b8b45b697d30/work"
            },
            "Name": "overlay2"
        },
        "RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:cd7100a72410606589a54b932cabd804a17f9ae5b42a1882bd56d263e02b6215",
                "sha256:f66908b454c81aae190cc6ae4f430edda3dba86b2c0ba92cadfe817153a6f841",
                "sha256:d2e3740a7dc7513f02913179b3090d6bc6581cf3e7ffa9ebea946403643ee55a"
            ]
        },
        "Metadata": {
            "LastTagTime": "2019-04-30T20:06:08.366158681+02:00"
        }
    }
]

我在这里看到了类似的问题,但没有一个与我的问题有关。

答案

我通过禁用CGO解决了这个问题

CGO_ENABLED=0 go build -o accountservice-linux-amd64

下一步

docker build -t someprefix/accountservice accountservice/
Sending build context to Docker daemon  8.439MB
Step 1/4 : FROM iron/base
 ---> b438fe7f76e9
Step 2/4 : EXPOSE 6767
 ---> Running in b3e84e962cf8
Removing intermediate container b3e84e962cf8
 ---> 924d21d06a29
Step 3/4 : ADD accountservice-linux-amd64 /
 ---> b92d16e8701b
Step 4/4 : ENTRYPOINT ["./accountservice-linux-amd64"]
 ---> Running in cb311a684b5a
Removing intermediate container cb311a684b5a
 ---> 1aedce37d586
Successfully built 1aedce37d586
Successfully tagged someprefix/accountservice:latest

没有任何问题与docker运行

 docker run --rm someprefix/accountservice
Starting accountservice
Seeded 100 fake accounts...
2019/05/01 08:35:34 Starting HTTP service at 6767

以上是关于为什么Docker运行失败? exec用户进程导致“没有这样的文件或目录”的主要内容,如果未能解决你的问题,请参考以下文章

运行docker容器时出错:启动容器进程导致“exec:”python “:$ PATH中找不到可执行文件”:未知

Raspberry-pi docker 错误:standard_init_linux.go:178:exec 用户进程导致“exec 格式错误”

standard_init_linux.go:219: exec 用户进程导致:没有这样的文件或目录 - docker 问题

standard_init_linux.go:178: exec 用户进程导致“exec 格式错误”

Docker buildx 与 Apple M1 Silicon 上的节点应用程序 -standard_init_linux.go:211:exec 用户进程导致“exec 格式错误”

“exec:”go “:$ PATH中找不到可执行文件”