I created a docker image from openjdk:8-jdk-alpine but when I try to execute simple commands I get the following errors:
RUN bash
/bin/sh: bash: not found
RUN ./gradlew build
env: can't execute 'bash': No such file or directory
Join Stack Overflow to learn, share knowledge, and build your career.
I created a docker image from openjdk:8-jdk-alpine but when I try to execute simple commands I get the following errors:
RUN bash
/bin/sh: bash: not found
RUN ./gradlew build
env: can't execute 'bash': No such file or directory
Alpine docker image doesn't have bash installed by default. You will need to add following commands to get bash
:
RUN apk update && apk add bash
If youre using Alpine 3.3+
then you can just do
RUN apk add --no-cache bash
to keep docker image size small. (Thanks to comment from @sprkysnrky)
RUN /bin/sh
instead of RUN bin/bash
– Alex Montoya
Apr 20 '20 at 2:07
Try using RUN /bin/sh
instead of bash.
bash
package adds about 4MB to the size of alpine:3.8
, roughly doubling it, but still far from 50MB.
– valiano
Feb 1 '19 at 14:02
RUN /bin/sh -c "apk add --no-cache bash"
worked for me.
RUN apk add --no-cache bash
directly
– Meiogordo
Apr 1 '20 at 16:26
To Install bash you can do:
RUN apk add --update bash && rm -rf /var/cache/apk/*
If you do not want to add extra size to your image, you can use ash
or sh
that ships with alpine.
Reference: https://github.com/smebberson/docker-alpine/issues/43
docker run --rm -i -t alpine /bin/sh
– Nabil Kadimi Sep 12 '18 at 20:44