使用 Docker 构建我的 Web 应用程序时出错
Error building my web application using Docker
我是使用 Docker 的新手,我已经在 Django 中完成了我的 Web 应用程序,我想使用 Docker 将其容器化。我已经完成了一个特定的教程,其中现有的 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
Docker文件
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
我能够通过删除代码的第二行并将我的代码重组为如下所示来解决问题:
Docker 文件
FROM python:3
WORKDIR /app
ADD . /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app
我是使用 Docker 的新手,我已经在 Django 中完成了我的 Web 应用程序,我想使用 Docker 将其容器化。我已经完成了一个特定的教程,其中现有的 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
Docker文件
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
我能够通过删除代码的第二行并将我的代码重组为如下所示来解决问题:
Docker 文件
FROM python:3
WORKDIR /app
ADD . /app
COPY ./requirements.txt /app/requirements.txt
RUN pip install -r requirements.txt
COPY . /app