docker build
时,一切似乎都可以正常工作,但是当我使用docker compose
时,这些文件似乎无法正确更新。
Dockerfile
是:
FROM python:3.10-alpine
# Install Imagemagick package
# gcc and more are required to build the uswgi wheel
RUN apk add imagemagick imagemagick-dev imagemagick-pdf gcc python3-dev build-base linux-headers pcre-dev curl
# set environment variables
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
COPY requirements.txt /
RUN pip install -r requirements.txt
COPY django_app/ /app
COPY uwsgi.ini /
WORKDIR /app
RUN python ./manage.py migrate
RUN python ./manage.py collectstatic --noinput
docker-compoose.yml
:
services:
redis:
image: redis:7-alpine
celery_worker:
build:
context: .
dockerfile: ./Dockerfile
image: celery
command: celery -A bg_upgrades worker -l info
env_file:
- ./docker_env
depends_on:
- redis
uwsgi:
build:
context: .
dockerfile: ./Dockerfile
image: uwsgi
env_file:
- ./docker_env
command: uwsgi --ini /uwsgi.ini
volumes:
- django_app:/app/
- socket:/sock/
depends_on:
- redis
nginx:
build:
context: ./nginx
dockerfile: ./Dockerfile
volumes:
- django_app:/app/
- socket:/sock/
depends_on:
- redis
- uwsgi
- celery_worker
ports:
- 80:80
volumes:
django_app:
socket:
看其他答案,这是我尝试过的几件事:
docker compose up -d --build --force-recreate
docker compose build --no-cache
dockerui中的所有容器和图像删除更改图像中的图像名称
docker-compose.yml
之前添加命令
RUN rm -Rf /app/*
COPY
重新启动之前
docker compose down
,当我使用
django_app/my_app/template/pattern_form.html.j2
docker build -t my_app:0.1 .
)。码头组合中应用程序容器的名称是什么?因为我看不到任何可能是您的应用程序的服务。如果要在启动容器之前创建Docker映像,则需要在Docker-Compose中写入容器配置,以下是Golang应用程序的示例。我假设UWSGI,CELERY_WORKER,NGINX和REDIS不是您的应用程序。
Dockerfile