Skip to content
Advertisement

Error building my web application using Docker

I am a newbie using Docker, I have completed my web application in Django, and I want to containerize it using Docker. I have gone through a particular tutorial where an existing web application was dockerized successfully but when I tried the same method, I got an error which says Failed to execute script docker-compose

error logs

Building web

Traceback (most recent call last):
  File "composeclimain.py", line 67, in main
  File "composeclimain.py", line 126, in perform_command
  File "composeclimain.py", line 302, in build
  File "composeproject.py", line 468, in build
  File "composeproject.py", line 450, in build_service
  File "composeservice.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 "composeclimain.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

Advertisement

Answer

I was able to solve the issu by removing the second line of the code and restructuring my code to look like this:

Dockefile

FROM python:3

WORKDIR /app

ADD . /app

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

RUN pip install -r requirements.txt

COPY . /app
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement