Reputation: 3
I'm building an image using alpine linux as follows:
FROM alpine:3.7
RUN apk update \
apk upgrade \
apk add bash
CMD ["sh","ls"]
I'm expecting bash to be available in the container but when I run it it can't find bash
docker run -it --rm tmp:latest /bin/sh
/ # bash
/bin/sh: bash: not found
If anybody can help me understand why it's not available it would be much appreciated!
Upvotes: 0
Views: 1526
Reputation: 5198
Try adding &&
after each apk command, like the Dockerfile below. When docker builds your container, your original RUN
line expanded to the single command apk update apk upgrade apk add bash
instead of separate commands. So the apk add bash
command wasn't properly run when you built the image.
FROM alpine:3.7
RUN apk update \
&& apk upgrade \
&& apk add bash
CMD ["sh","ls"]
You should combine separate commands with &&
so if one fails, this will be reported when building the image.
Upvotes: 1