docker 此错误意味着什么:合成项目无效?

aemubtdh  于 2023-03-01  发布在  Docker
关注(0)|答案(1)|浏览(411)

我正在学习如何用docker运行django rest,我创建了一个映像,当我使用命令时,它可以工作:docker run -p 8000:8000 docker_django_tutorial但是现在我想通过一个docker-compose.yml文件运行这个图像。下面是我的(它基于一个youtube视频,这就是为什么我不明白为什么它不适合我):

version: '3'

services:
  monapp:
    image: docker_django_tutorial
    ports:
      - 8000:8000
    networks:
      - monreaseau

networks:
  monreseau:

当我运行docker-compose up时,我得到了以下错误:

service "monapp" refers to undefined network monreaseau: invalid compose project

为了以防万一,下面是我的图像docker_django_tutorial的Docker文件用法:

#Use the Python3.7.2 container image
FROM python:3.7.2-stretch
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
ENV PYTHONUNBUFFERED 1
CMD ["python3", "manage.py", "runserver", "0.0.0.0:8000"]
#RUN python3 manage.py runserver
oaxa6hgo

oaxa6hgo1#

谢谢你的回答。
有人帮我重写我的文件这样:
Docker文件:

#Use the Python3.7.2 container image
FROM python:latest
WORKDIR /app
COPY . /app
RUN pip install -r requirements.txt
ENV PYTHONUNBUFFERED 1
#CMD ["python3", "manage.py", "runserver", "0.0.0.0:90"]
#RUN python3 manage.py runserver

docker-compose.yml:版本:"3"

services:
  monapp:
    image: docker_django_tutorial
    ports:
      - 90:90
    build: .
    command: python3 manage.py runserver 0.0.0.0:90

相关问题