1

I'm having a little trouble trying to spool up an Alpine linux container.

My Dockerfile is very simple but I keep getting an error which i havent seen before.

My Dockerfile is as follows;

FROM openjdk:8-jre-alpine

RUN apk update && apk upgrade && apk --update add \
    ruby build-base libstdc++ tzdata bash ttf-dejavu freetype fontconfig wget curl

RUN addgroup -S newuser && adduser -S newuser -G newuser && \
    cd && cp -R .bashrc .profile /home/newuser && \
    mkdir -p /project && \
    chown -R newuser:newuser /home/newuser /project

USER newuser
ENV HOME /home/newuser

The errors i keep seeing are as follows;

cp: can't stat '.bashrc': No such file or directory
cp: can't stat '.profile': No such file or directory

I dont understand whats going on.

Could anyone shed some light on this? I have never used Alpine Linux before.

valiano
  • 16,433
  • 7
  • 64
  • 79
CodeSauce
  • 255
  • 3
  • 19
  • 39
  • Most common paths of running Docker containers just don't read shell dotfiles (or care about "home directories" for that matter). If you need to set an environment variable, use the Dockerfile `ENV` directive, and avoid any more complex customization. – David Maze Sep 27 '19 at 12:50
  • Possible duplicate of [How to use bash with an Alpine based docker image?](https://stackoverflow.com/questions/40944479/how-to-use-bash-with-an-alpine-based-docker-image) – leopal Sep 27 '19 at 13:50
  • (Adding `pwd && ls -al` in between the `cd` and the `cp` is probably also enlightening, but those files probably actually don't exist like the error message says.) – David Maze Sep 27 '19 at 14:08

2 Answers2

2

Alpine Linux only has the sh shell not the bash shell so I don't think that file would exist. I'm pretty sure you can install the bash shell and create your own .bashrc.

OpenBSDNinja
  • 1,037
  • 10
  • 18
0

Are you sure that the root's home directory actually contains .bashrc and .profile? More likely than not, these are not present. The default shell is ash. Have a look at the image contents.

Alen Siljak
  • 2,482
  • 2
  • 24
  • 29