1

I am writing a dockerfile, where one of its dependencies can only be installed only when a homedirectory exist, but how do I set something like that up?

ARG BUILD_FROM=raspbian/stretch:latest
FROM $BUILD_FROM


RUN apt-get -qq update \
    && apt-get -qq install -y --no-install-recommends \
        apt-transport-https \
        apt-utils \
        dirmngr \
        gnupg-curl \
        mpg123 \
        supervisor \
        unzip \
        curl \
        git \
        wget \
        python3 \

    && pip3 install -U setuptools && pip3 install utils\
    && pip3 install -r requirements.txt

requirements.txt

slugify
google-api-python-client
oauth2client
esptool

this can only be installed using pip3 install --user slugify which requires an homedir which I can't setup..

square
  • 11
  • 1
  • 3

2 Answers2

0

You can either create the dir manually by using a line like

RUN mkdir /home/slugify

or if you need a full user with permissions etc you can run

RUN adduser slugify

Read more at the manpage https://manpages.debian.org/jessie/adduser/adduser.8.sv.html

lijat
  • 640
  • 7
  • 16
  • @square in that case is the problem only the missing home directory or is there other parts to it such as a need to run as a specific user etc. If you show an error message we might be able to help more – lijat Jan 03 '20 at 08:03
0

I think there should be an user home set by default.

However, you can change it using usermod -d /newhome/username username:

RUN mkdir /homedir
RUN usermod -d /homedir root

Maybe the program just needs an environment variable HOME:

RUN HOME=/homedir;<install command>
dan1st
  • 12,568
  • 8
  • 34
  • 67