Docker:由于缺少 bash,无法编辑图像中的代码

标签 docker ubuntu

我在 AWS 服务器上运行 Ubuntu 18。在该服务器中,我有一个 Docker 镜像,我想在它仍在运行时更改它的代码。

ubuntu@ip-172-31-6-79:~$ docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
fc                         latest              20949d0fd7ec        7 days ago          1.74GB
debian                     latest              8d31923452f8        5 weeks ago         101MB
ekholabs/face-classifier   latest              b1a390b8ec60        21 months ago       1.77GB

为了更改代码,我运行了以下命令
ubuntu@ip-172-31-6-79:~$ docker run -it fc bash

但我收到以下错误
python3: can't open file 'bash': [Errno 2] No such file or directory

我该如何解决这个问题,以便我可以编辑 Docker 镜像中的代码。作为旁注,这里是 Dockerfile
FROM debian:latest

RUN apt-get -y update && apt-get install -y git python3-pip python3-dev python3-tk vim procps curl

#Face classificarion dependencies & web application
RUN pip3 install numpy scipy scikit-learn pillow tensorflow pandas h5py opencv-python==3.2.0.8 keras statistics pyyaml pyparsing cycler matplotlib Flask

ADD . /ekholabs/face-classifier

WORKDIR ekholabs/face-classifier

ENV PYTHONPATH=$PYTHONPATH:src
ENV FACE_CLASSIFIER_PORT=8084
EXPOSE $FACE_CLASSIFIER_PORT

ENTRYPOINT ["python3"]
CMD ["src/web/faces.py"]

最佳答案

问题出在您使用的 dockerfile 上

ENTRYPOINT ["PYTHON3"]



这意味着当你运行时

docker run -it fc bash



它在容器内转换为“python3 bash”这就是你有错误的原因

python3: can't open file 'bash': [Errno 2] No such file or directory



尝试删除 ENTRYPOINT

希望能解决问题。

关于Docker:由于缺少 bash,无法编辑图像中的代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56651010/

相关文章:

bash - 我想编写一个在多个新终端中启动命令的 bashrc 别名

docker-compose 有效,但 heroku.yml 失败?

java - opencv 3.2.0 java 人脸识别 Ubuntu

ubuntu - 如何在 Ubuntu 11.10 和 Ubuntu 12.04 LTS 上安装 Clojure 1.5

docker - 如何在生产中的服务之间共享源代码?

ruby-on-rails - “未安装 bundle ”错误

ubuntu - 错误 : Failed finding Lua library. 您可能需要配置 LUA_LIBDIR

node.js - 如何动态更改通过docker运行的 Node 项目中的内容

sql-server - 如何在 SQL Server Docker 容器中使用 Windows 身份验证

docker - docker-compose.yml不会读取主机名的环境变量