[英]“bin/bash: python: command not found” returned when running docker image
Here is the docker run
output:这是docker run
output:
hausey@ubuntu:~/niso2-jxj934$ docker run niso2-jxj934
Test version: 15:59, Mar 24th 2020
Question 1: Evaluation of expression.
Command failed: /bin/bash -c "python /bin/jxj934.py -question 1 -expr \"(ifleq (ifleq -1.11298616747 1.63619642199 (sub -1.11298616747 -1.11298616747) 1.7699684348) (add (exp -0.822479932786) 1.39992604386) (add -1.11298616747 (exp 0.385042309638)) 0.205973267133)\" -n 10 -x \"-0.168958230447 -0.131749160548 0.0971246476126 1.8706205565 -0.464122426299 2.35887369763 -0.375948313434 -0.613901105864 0.411326743135 -0.149276696072\"" Exit status: exited with code 127 stderr: /bin/bash: python: command not found
Here is the Dockerfile:这是 Dockerfile:
FROM pklehre/niso2020-lab2-msc
ADD jxj934.py /bin
CMD ["-username","jxj934", "-submission", "python /bin/jxj934.py"]
Here is check for python
:这是检查python
:
hausey@ubuntu:~/niso2-jxj934$ which python
/usr/bin/python
Is that related to the PATH of python?这与 python 的路径有关吗?
Usually, it is related to the value of PATH
but, specifically, that image only has python3
.通常,它与PATH
的值有关,但具体来说,该图像只有python3
。 In other words, looking through the filesystem with换句话说,通过文件系统查看
find / -name -type f "python*"
Look for regular files named "python*" in
/
在/
中查找名为“python*”的常规文件
There were only python3
results.只有python3
结果。
...
/usr/bin/python3.8
/usr/bin/python3.7
...
A quick solution is to specify python3
in your CMD line ( python3 /bin/jxj934.py
).一个快速的解决方案是在您的 CMD 行 ( python3 /bin/jxj934.py
) 中指定python3
。 Another is to add a soft link ( ln -s /usr/bin/python /usr/bin/python3.8
).另一种是添加软链接( ln -s /usr/bin/python /usr/bin/python3.8
)。 The best solution is to solve it using the package manager.最好的解决方案是使用 package 管理器来解决它。 Then again, that depends if you're in control of the Dockerfile
+ image.再说一次,这取决于您是否控制了Dockerfile
+ 图像。
When you queried which python
, you did so on your local machine.当您查询which python
时,您是在本地计算机上进行的。 The container runs in a different filesystem namespace than yours and with a completely different terminal.该容器在与您的不同的文件系统命名空间中运行,并且使用完全不同的终端。 The container will behave differently than your machine and any such investigations will yield relevant results only when run within the container.容器的行为与您的机器不同,任何此类调查只有在容器内运行时才会产生相关结果。
A little unrelated to your question but it might serve you.与您的问题有点无关,但它可能对您有用。
docker run
has a --entrypoint
option that allows you to override the image's entrypoint. docker run
有一个--entrypoint
选项,允许您覆盖图像的入口点。 You can ask for bash and explore the container.您可以询问 bash 并探索容器。
docker run --it --entrypoint=bash pklehre/niso2020-lab2-msc
Note that
bash
has to be in the $PATH.请注意,bash
必须在 $PATH 中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.