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
JavaScript
x
19
19
1
Building web
2
3
Traceback (most recent call last):
4
File "composeclimain.py", line 67, in main
5
File "composeclimain.py", line 126, in perform_command
6
File "composeclimain.py", line 302, in build
7
File "composeproject.py", line 468, in build
8
File "composeproject.py", line 450, in build_service
9
File "composeservice.py", line 1147, in build
10
compose.service.BuildError: (<Service: web>, {'message': 'dockerfile parse error line 1: FROM requires either one or three arguments'})
11
12
During handling of the above exception, another exception occurred:
13
14
Traceback (most recent call last):
15
File "docker-compose", line 3, in <module>
16
File "composeclimain.py", line 78, in main
17
TypeError: can only concatenate str (not "dict") to str
18
[11920] Failed to execute script docker-compose
19
Dockerfile
JavaScript
1
14
14
1
FROM python: 3
2
3
ENV: PYTHONUNBUFFERED 1
4
5
WORKDIR /app
6
7
ADD . /app
8
9
COPY ./requirements.txt /app/requirements.txt
10
11
RUN pip install -r requirements.txt
12
13
COPY . /app
14
docker-compose.yml
JavaScript
1
9
1
version: '3'
2
3
services:
4
web:
5
build: .
6
command: python manage.py runserver 0.0.0.0:8000
7
ports:
8
- 8000:8000
9
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
JavaScript
1
12
12
1
FROM python:3
2
3
WORKDIR /app
4
5
ADD . /app
6
7
COPY ./requirements.txt /app/requirements.txt
8
9
RUN pip install -r requirements.txt
10
11
COPY . /app
12