[英]Permission Denied When Installing Packages Using Pip In Docker Container Django
I'm unable to install the package inside my docker container, please let me know how can I solve this.我无法在我的 docker 容器中安装 package,请告诉我如何解决这个问题。
Warning:警告:
WARNING: The directory '/home/app/.cache/pip' or its parent directory is not owned or is not writable by the current user.
警告:目录 '/home/app/.cache/pip' 或其父目录不属于当前用户或不可写。 The cache has been disabled.
缓存已被禁用。 Check the permissions and owner of that directory.
检查该目录的权限和所有者。 If executing pip with sudo, you should use sudo's -H flag.
如果使用 sudo 执行 pip,则应使用 sudo 的 -H 标志。
error:错误:
ERROR: Could not install packages due to an OSError: [Errno 13] Permission denied: '/home/app'
Check the permissions.
Dockerfile: Dockerfile:
FROM python:3
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
EXPOSE 8000
COPY ./core/ /app/
COPY ./scripts /scripts
RUN pip install --upgrade pip
COPY requirements.txt /app/
RUN pip install -r requirements.txt && \
adduser --disabled-password --no-create-home app && \
mkdir -p /vol/web/static && \
mkdir -p /vol/web/media && \
chown -R app:app /vol && \
chmod -R 755 /vol && \
chmod -R +x /scripts
USER app
CMD ["/scripts/run.sh"]
command inside container:容器内的命令:
pip install django-storages
In my case, I've installed the package using the root user by adding -u 0
which tells docker to go in as root user.在我的例子中,我已经使用 root 用户安装了 package,方法是添加
-u 0
告诉 docker 到 go 以 root 用户身份。
docker exec -u 0 -it mycontainer bash
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.