Bash 高山 linux

Bash on alpine linux

我无法将 bash shell 放入高山容器中。

我从这个 Alpine 容器开始: gitlab/gitlab-runner:alpine

我要在这个 dockerfile 中添加 bash shell 和其他配置:

from gitlab/gitlab-runner:alpine

ENV http_proxy=<corporate_proxy>
ENV https_proxy=<corporate_proxy>

RUN apk add vim wget curl nmap lsof bash bash-completion which

CMD ["/bin/bash"]
RUN ls -l /bin # THIS WORKS, I CAN SEE 'BASH' SHOW UP WITH 755 OWNED BY ROOT
RUN which bash # THIS ALSO WORKS
RUN /bin/bash -c "echo hi" # YES, THIS WORKS TOO

然而,当通过以下方式生成容器以使用 bash shell 时: docker run -idt <image_name> /bin/bash,容器启动失败FATAL: Command /bin/bash not found.

请注意,在生成容器时,这些其他选项对我来说也会失败:ash, sh, /bin/ash, /bin/sh, etc

运行带--user root的容器也不行。

1- 验证您的容器是否已满载:

docker ps

所以在输入 bash shell 之后,例如:

docker exec -it <<container_name>> bash

原来在容器的入口点设置了一些奇怪的东西。我需要记住在通过 docker run.

生成新容器时覆盖入口点

在 Dockerfile 中添加这一行解决了问题:

ENTRYPOINT: []

入口点是 GitLab Runner 脚本。将其更改为 bash 以获得 shell 访问权限:

$ docker run -it --entrypoint /bin/bash <image_name>