django - Docker 中的 Django 应用程序给出 FileNotFoundError: [Errno 2] No such file or directory: '/tmp/
问题描述
我正在使用带有图像的Docker来对Django应用程序进行 dockerize。python:3.7.6-slim
我正在使用django-import-export插件在管理面板中导入数据,该管理面板将上传的文件存储在临时目录中以在导入时读取。
但是在导入时,它给出了一个错误
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmppk01nf3d'
不使用 docker 时也是如此。
Dockerfile
FROM python:3.7.6-slim
ARG APP_USER=appuser
RUN groupadd -r ${APP_USER} && useradd --no-log-init -r -g ${APP_USER} ${APP_USER}
RUN set -ex \
&& RUN_DEPS=" \
libpcre3 \
mime-support \
default-libmysqlclient-dev \
inkscape \
libcurl4-nss-dev libssl-dev \
" \
&& seq 1 8 | xargs -I{} mkdir -p /usr/share/man/man{} \
&& apt-get update && apt-get install -y --no-install-recommends $RUN_DEPS \
&& pip install pipenv \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /home/${APP_USER}/.config/inkscape \
&& chown -R ${APP_USER} /home/${APP_USER}/.config/inkscape \
# Create directories
&& mkdir /app/ \
&& mkdir /app/config/ \
&& mkdir /app/scripts/ \
&& mkdir -p /static_cdn/static_root/ \
&& chown -R ${APP_USER} /static_cdn/
WORKDIR /app/
COPY Pipfile Pipfile.lock /app/
RUN set -ex \
&& BUILD_DEPS=" \
build-essential \
libpcre3-dev \
libpq-dev \
" \
&& apt-get update && apt-get install -y --no-install-recommends $BUILD_DEPS \
&& pipenv install --deploy --system \
\
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $BUILD_DEPS \
&& rm -rf /var/lib/apt/lists/*
COPY ./src /app/
COPY scripts/ /app/scripts/
COPY configs/ /app/configs/
EXPOSE 8000
ENV UWSGI_WSGI_FILE=qcg/wsgi.py
ENV UWSGI_HTTP=:8000 UWSGI_MASTER=1 UWSGI_HTTP_AUTO_CHUNKED=1 UWSGI_HTTP_KEEPALIVE=1 UWSGI_LAZY_APPS=1 UWSGI_WSGI_ENV_BEHAVIOR=holy
ENV UWSGI_WORKERS=2 UWSGI_THREADS=4
ENV UWSGI_STATIC_MAP="/static/=/static_cdn/static_root/" UWSGI_STATIC_EXPIRES_URI="/static/.*\.[a-f0-9]{12,}\.(css|js|png|jpg|jpeg|gif|ico|woff|ttf|otf|svg|scss|map|txt) 315360000"
USER ${APP_USER}:${APP_USER}
ENTRYPOINT ["/app/scripts/docker/entrypoint.sh"]
和运行命令
docker run my-image uwsgi --show-config
解决方案
推荐阅读
- angular - Angular Material Flex MediaObserver 订阅了两次
- amazon-web-services - AWS Systems Manager (SSM) 无法更新 SageMaker 实例上的InstanceInformation
- android - Phonegap / Cordova 删除应用程序数据 / 文件 / 一切更新
- javascript - Dropzone Js 没有上传我的文件 [Code Igniter]
- android - 如何使用 FCM 在应用程序之间发送通知
- python - 比较两个 PySpark 数据帧并修改其中一个?
- sql-server - 从两个表中选择,其中第一个表列包含要从第二个表中获取的列的名称
- python - 仅绘制 matplot lib 中 datetime 对象的时间
- python - pip配置不好?
- python - 正则表达式函数删除除指定表达式之外的所有数字和标点符号?