为什么泊坞窗不允许我在没有交互式会话的情况下执行二进制文件?

时间:2019-06-21 14:30:25

标签: docker dockerfile

我熟悉docker,但遇到了障碍。我试图在不运行交互式会话的情况下从终端调用可执行文件。我目前可以通过执行以下两个命令来完成此操作:

docker run --rm -it -v $PWD/face/:/home/openface-build algebr/openface:latest 
build/bin/FeatureExtraction -f ./face/officespace.mp4

我正在尝试编写如下所示的命令:

docker run --rm -v $PWD/face/:/home/openface-build algebr/openface:latest ./build/bin/FeatureExtraction -f ./face/officespace.mp4

但是,执行时出现错误,提示我无法执行二进制文件。如果我尝试运行

,我也会得到这个
docker run --rm -v $PWD/face/:/home/openface-build algebr/openface:latest bash

这是我的docker image inspect命令中的内容

 "ContainerConfig": {
            "Hostname": "1bc488685a5e",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "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 [\"/bin/bash\"]"
            ],
            "ArgsEscaped": true,
            "Image": "sha256:c7625f34563c9af6cc837f8ccc202a61070a5f702888a06f15e4184b497da049",
            "Volumes": null,
            "WorkingDir": "/home/openface-build",
            "Entrypoint": [
                "/bin/bash"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "Edgar Aroutiounian <edgar.factorial@gmail.com>"
            }
        },
        "DockerVersion": "18.03.1-ce",
        "Author": "",
        "Config": {
            "Hostname": "",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "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:c7625f34563c9af6cc837f8ccc202a61070a5f702888a06f15e4184b497da049",
            "Volumes": null,
            "WorkingDir": "/home/openface-build",
            "Entrypoint": [
                "/bin/bash"
            ],
            "OnBuild": null,
            "Labels": {
                "maintainer": "Edgar Aroutiounian <edgar.factorial@gmail.com>"
            }
        },

Also it should be noted that in order to replicate this problem, I had to copy the original contents of container $ /home/openface-build/ to localhost$ ~/face so that they merge as a union 

1 个答案:

答案 0 :(得分:0)

如果您查看Dockerfile for that base image,则以该行结尾

ENTRYPOINT ["/bin/bash"]

这意味着您作为参数传递给docker run的任何命令实际上都将作为bash的参数给出-对于您的docker run命令,Docker实际上正在运行

/bin/bash build/bin/FeatureExtraction -f ./face/officespace.mp4

该文件可能不是Shell脚本,会导致您收到错误消息。

未经修改的ubuntu映像的默认行为实际上是在启动时启动shell,因此上游作者可能应该从Dockerfile中删除该行;它没有实际效果,会给您带来麻烦。

解决此问题的尴尬方法是提供要运行的二进制文件作为入口点。

docker run ... \
  --entrypoint build/bin/FeatureExtraction \
  algebr/openface:latest \
  -f ./face/officespace.mp4