Docker-compose not building up successfully

205 Views Asked by At

On running docker-compose up -d --build I am getting the following error:

PS C:\Users\KELLYRYAN\Documents\august-code\drf_course\drf_course> docker-compose up -d --build [+] Building 128.5s (11/18) => [api internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s => [api internal] load build definition from Dockerfile 0.1s => => transferring dockerfile: 532B 0.0s => [api internal] load metadata for docker.io/library/python:3.10 2.0s => [app internal] load build definition from Dockerfile_app 0.1s => => transferring dockerfile: 409B 0.0s => [app internal] load .dockerignore 0.1s => => transferring context: 2B 0.0s => [api auth] library/python:pull token for registry-1.docker.io 0.0s => CACHED [app 1/5] FROM docker.io/library/python:3.10@sha256:b24f2d9aaa0093ee4fa95a1a524badbaed4d5c7fda68ae6005b8145973183f8b 0.0s => [app internal] load build context 0.1s => => transferring context: 31B 0.0s => [api internal] load build context 0.1s => => transferring context: 2.22kB 0.0s => CANCELED [api 2/6] RUN set -e; apt-get update ; apt-get -y install netcat ; apt-get -y install gettext ; 126.4s => ERROR [app 2/5] RUN set -e; apt-get update ; apt-get -y install netcat ; apt-get -y install gettext ; apt-get -y install httpie; pip install --upgrade p 126.2s ------

failed to solve: process "/bin/sh -c set -e; apt-get update ; apt-get -y install netcat ; apt-get -y install gettext ; apt-get -y install httpie; pip install --upgrade pip pip install flask" did not complete successfully: exit code: 100

I am using windows 10. And I have tried restarting docker a couple of times and rerunning the command but nothing seems to change.

My file structure looks like this file structure

What could be the problem as I cannot find links to solve this for windows?

2

There are 2 best solutions below

2
On

I think a ";" is missing between pip install --upgrade pip and pip install flask

0
On

The issue was with netcat as well as a missing semicolon as explained above by @chc.

This can be fixed by editing the (1) Dockerfile from this:

RUN set -e; \
apt-get update ;\
apt-get -y install netcat ;\ 
apt-get -y install gettext ;

RUN mkdir /code
COPY . /code/
WORKDIR /code

RUN set -e; \
/usr/local/bin/python -m pip install --upgrade pip ;\
python -m pip install -r /code/requirements.txt ;\
chmod +x /code/docker/entrypoints/entrypoint.sh ;

EXPOSE 8000
ENTRYPOINT ["/code/docker/entrypoints/entrypoint.sh"]

to this:

RUN set -e; \
apt-get update ;\
apt-get -y install netcat-traditional;\ 
apt-get -y install gettext ;

(2)and the Dockerfile_app, from this:

RUN set -e; \
apt-get update ;\
apt-get -y install netcat ;\
apt-get -y install gettext ;\
apt-get -y  install httpie; \
pip install --upgrade pip \
pip install flask

to this:

RUN set -e; \
apt-get update ;\
apt-get -y install netcat-traditional ;\
apt-get -y install gettext ;\
apt-get -y  install httpie; \
pip install --upgrade pip; \
pip install flask

Run the command docker-compose up -d --build successfully.