Docker: How to use bash with an Alpine based docker image?

Try using RUN /bin/sh instead of bash.


Alpine docker image doesn't have bash installed by default. You will need to add the following commands to get bash:

RUN apk update && apk add bash

If you're using Alpine 3.3+ then you can just do:

RUN apk add --no-cache bash

To keep the docker image size small. (Thanks to comment from @sprkysnrky)

If you just want to connect to the container and don't need bash, you can use:

docker run --rm -i -t alpine /bin/sh --login

RUN /bin/sh -c "apk add --no-cache bash"

worked for me.