Search code examples
dockeralpine-linux

Bash on alpine linux


I cannot get a bash shell into an alpine container.

I'm starting with this Alpine container: gitlab/gitlab-runner:alpine

I'm adding a bash shell and other configs in this dockerfile:

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

However when spawning the container to use a bash shell via: docker run -idt <image_name> /bin/bash, the container fails to start with FATAL: Command /bin/bash not found.

Note that these other options also fail for me when spawning a container: ash, sh, /bin/ash, /bin/sh, etc

running the container with --user root also does not work.


Solution

  • The entrypoint is a GitLab Runner script. Change it to bash to get shell access:

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