繁体   English   中英

使用 Docker 构建我的 web 应用程序时出错

[英]Error building my web application using Docker

我是使用 Docker 的新手,我已经在 Django 中完成了我的 web 应用程序,我想使用 Z23B4FD214CDD0D2 将其容器化。 我已经完成了一个特定的教程,其中现有的 web 应用程序已成功 dockerized,但是当我尝试相同的方法时,我收到一个错误,提示Failed to execute script docker-compose

错误日志

Building web

Traceback (most recent call last):
  File "compose\cli\main.py", line 67, in main
  File "compose\cli\main.py", line 126, in perform_command
  File "compose\cli\main.py", line 302, in build
  File "compose\project.py", line 468, in build
  File "compose\project.py", line 450, in build_service
  File "compose\service.py", line 1147, in build
compose.service.BuildError: (<Service: web>, {'message': 'dockerfile parse error line 1: FROM requires either one or three arguments'})

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 78, in main
TypeError: can only concatenate str (not "dict") to str
[11920] Failed to execute script docker-compose

Dockerfile

FROM python: 3

ENV: PYTHONUNBUFFERED 1

WORKDIR /app

ADD . /app

COPY ./requirements.txt /app/requirements.txt

RUN pip install -r requirements.txt

COPY . /app

docker-compose.yml

version: '3'

services:
  web:
    build: .
    command: python manage.py runserver 0.0.0.0:8000
    ports:
      - 8000:8000

我能够通过删除代码的第二行并将我的代码重组为如下所示来解决问题:

码头文件

FROM python:3

WORKDIR /app

ADD . /app

COPY ./requirements.txt /app/requirements.txt

RUN pip install -r requirements.txt

COPY . /app

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM