我在docker容器中运行一个Django应用程序。我得到了这个错误sqlite3.OperationalError: attempt to write a readonly database
。我试过Dockerfile里的所有东西
RUN chown username db.sqlite3
RUN chmod 777 db.sqlite3
我还尝试以root用户身份运行应用程序,但仍然收到相同的错误。
这是我的Dockerfile
FROM python:3.9.5-alpine
RUN addgroup -S apigroup && adduser -S weatherapi -G apigroup
WORKDIR /app
ADD requirements.txt .
RUN apk update && apk upgrade
RUN python3 -m pip install --upgrade pip && python3 -m pip install --no-cache-dir -r requirements.txt
COPY . .
USER root
EXPOSE 8000
RUN chmod 777 db.sqlite3
USER weatherapi
RUN python3 manage.py migrate
CMD ["sh", "-c", "python3 manage.py runserver 0.0.0.0:8000"]
还有我的码头-作曲
version: '3.7'
networks:
weather_api_net:
driver: bridge
driver_opts:
com.docker.network.enable_ipv6: "false"
services:
web:
restart: unless-stopped
image: weatherapi:1.0
container_name: weatherapi
ports:
- "8000:8000"
volumes:
- .:/app
deploy:
replicas: 1
update_config:
parallelism: 2
delay: 10s
order: start-first
rollback_config:
parallelism: 2
delay: 10s
failure_action: continue
monitor: 60s
order: stop-first
restart_policy:
condition: on-failure
networks:
- weather_api_net
发布于 2021-06-24 21:25:21
我只需将基础镜像更改为基于Debian的镜像。
FROM python:3.8-buster
显然阿尔卑斯不喜欢SQLite。
https://stackoverflow.com/questions/68109008
复制相似问题