'How to install pip packages with Dockerfile? Getting permission restrictions error
I have the following Dockerfile that I use to deploy an Rasa Bot app on Google's App Engine:
FROM rasa/rasa
ENV BOT_ENV=development
COPY . /var/www
WORKDIR /var/www
RUN pip install rasa phonenumbers pgeocode
#ENTRYPOINT ["rasa", "run", "-vv", "--enable-api", "actions"]
ENTRYPOINT ["rasa", "run", "-vv", "--enable-api", "--endpoints", "endpoints.yml", "--credentials", "credentials.yml", "-p", "8080"]
But the deployment fails to install the phonenumbers and pgeocode packages, somehow doesn't have problem with rasa.
The error I get is this:
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/build/lib/python3.6/site-packages/phonenumbers'
Consider using the `--user` option or check the permissions.
The command '/bin/sh -c pip install rasa phonenumbers pgeocode' returned a non-zero code: 1
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/docker" failed: step exited with non-zero status: 1
I have tried using the --user as suggested, and in some other questions I saw answers suggesting using sudo with -H flag, but that as well fails, with a different error saying that sudo is not recognized.
If I remove those 2 failing packages, my app runs, except that it can't perform some actions for which those packages are needed.
Any idea how I can solve this?
Thanks!
Solution 1:[1]
USER root worked for me too. For future ppl, don't forget to set USER back as per http://redhatgov.io/workshops/security_containers/exercise1.2/
i.e: USER root ... USER 1001 (or whatever user you want)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Bart?omiej Pa?us |
