docker-compose up --build 指出错误,但在我使用 docker-compose up 后它起作用了

docker-compose up --build states an error but it works after i use docker-compose up what is the problem which gives me the error

我在下面添加了代码,希望它清晰准确

Docker 文件:

FROM python:3.8.5-alpine

RUN pip install --upgrade pip

COPY ./requirements.txt .
RUN pip install -r requirements.txt

COPY ./ddc /app

WORKDIR /app

COPY ./entrypoint.sh /
ENTRYPOINT ["sh", "/entrypoint.sh"]

docker-compose.yml

version: '3.7'

services:
  django_gunicorn:
    volumes:
      - static:/static
    env_file:
      - .env
    build:
      context: .
    ports:
      - "8000:8000"
  
  nginx:
    build: ./nginx
    volumes:
      - static:/static
    ports:
      - "80:80"
    depends_on:
      - django_gunicorn

volumes:
  static:

entrypoint.sh

#!/bin/sh

python manage.py migrate --no-input
python manage.py collectstatic --no-input

gunicorn ddc.wsgi:application --bind 0.0.0.0:8000
    

                                                                                                             

首先我使用docker-compose up --build

这就是我得到的:

Building django_gunicorn
Sending build context to Docker daemon  19.46kB
Step 1/8 : FROM python:3.8.5-alpine
 ---> 0f03316d4a27
Step 2/8 : RUN pip install --upgrade pip
 ---> Using cache
 ---> ac5d6a64af93
Step 3/8 : COPY ./requirements.txt .
 ---> Using cache
 ---> 8dfb848be8a4
Step 4/8 : RUN pip install -r requirements.txt
 ---> Using cache
 ---> 0dee442b9c0a
Step 5/8 : COPY ./ddc /app
 ---> 21c33e5463d8
Step 6/8 : WORKDIR /app
 ---> Running in 9153438d9466
Removing intermediate container 9153438d9466
 ---> d27b60805a1b
Step 7/8 : COPY ./entrypoint.sh /
 ---> e497fecdfb76
Step 8/8 : ENTRYPOINT ["sh", "/entrypoint.sh"]
 ---> Running in f6eb59759a71
Removing intermediate container f6eb59759a71
 ---> 6db361baa8e8
Successfully built 6db361baa8e8
Successfully tagged django-docker-compose_django_gunicorn:latest
Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose/cli/main.py", line 81, in main
  File "compose/cli/main.py", line 203, in perform_command
  File "compose/metrics/decorator.py", line 18, in wrapper
  File "compose/cli/main.py", line 1186, in up
  File "compose/cli/main.py", line 1182, in up
  File "compose/project.py", line 664, in up
  File "compose/service.py", line 348, in ensure_image_exists
  File "compose/service.py", line 1133, in build
  File "compose/service.py", line 1948, in build
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmp5cv0a52z'
[22049] Failed to execute script docker-compose

之后我就用 docker-撰写

并且系统按预期运行。这个错误是什么意思,我该如何避免。我使用最新的 docker 和 compose 是:

docker:Docker version 19.03.13, build cd8016b6bc
docker-compose version 1.29.2, build 5becea4c

我将安装从 ubuntu 快照更改为

后问题得到解决

https://docs.docker.com/engine/install/ubuntu/

https://docs.docker.com/compose/install/