Docker Build - HTTP error 503 Server Error: Backend is unhealthy - docker

Question :- What Backend does this Error refer to when it states - "because of error 503 Server Error: Backend is unhealthy for URL https://files.pythonhosted.org/packages/....
Am using a Dockerfile for the build. Image was built a few hours back with same Dockerfile. Now getting this ERROR -
Entire trace :
dhankar#dhankar-VPCEB44EN:/media/dhankar/Dhankar_1/a2_18/a2___DC_API/aa___Docker_RESTAPI$ sudo docker build -t ddrohit/dck1 .
Sending build context to Docker daemon 1.862MB
Step 1/11 : FROM ubuntu:xenial
---> c9d990395902
Step 2/11 : RUN apt-get update
---> Using cache
---> 42f625ed03cb
Step 3/11 : RUN apt-get install -y python3 # install python3
---> Using cache
---> 393d9e7b20ec
Step 4/11 : RUN apt-get install -y python-pip python-dev build-essential
---> Using cache
---> bb956f271bdd
Step 5/11 : COPY ./ /usr/src/rest_api/
---> Using cache
---> 50d0d52e8e22
Step 6/11 : WORKDIR /usr/src/rest_api/
---> Using cache
---> 42e086f6d8c4
Step 7/11 : RUN pip install --upgrade pip
---> Running in d56c0d5cafce
Collecting pip
HTTP error 503 while getting https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl#sha256=86a60a96d85e329962a9e6f6af612cbc11106293dbc83f119802b5bee9874cf3 (from https://pypi.org/simple/pip/)
Could not install requirement pip from https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl#sha256=86a60a96d85e329962a9e6f6af612cbc11106293dbc83f119802b5bee9874cf3 because of error 503 Server Error: Backend is unhealthy for url: https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl
Could not install requirement pip from https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl#sha256=86a60a96d85e329962a9e6f6af612cbc11106293dbc83f119802b5bee9874cf3 because of HTTP error 503 Server Error: Backend is unhealthy for url: https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl for URL https://files.pythonhosted.org/packages/62/a1/0d452b6901b0157a0134fd27ba89bf95a857fbda64ba52e1ca2cf61d8412/pip-10.0.0-py2.py3-none-any.whl#sha256=86a60a96d85e329962a9e6f6af612cbc11106293dbc83f119802b5bee9874cf3 (from https://pypi.org/simple/pip/)
You are using pip version 8.1.1, however version 10.0.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The command '/bin/sh -c pip install --upgrade pip' returned a non-zero code: 1
dhankar#dhankar-VPCEB44EN:/media/dhankar/Dhankar_1/a2_18/a2___DC_API/aa___Docker_RESTAPI$
My Dockerfile :-
#
FROM ubuntu:xenial
RUN apt-get update
RUN apt-get install -y python3 # install python3
RUN apt-get install -y python-pip python-dev build-essential
#
COPY ./ /usr/src/rest_api/
WORKDIR /usr/src/rest_api/
#
RUN pip install -r /usr/src/rest_api/requirements.txt
#
EXPOSE 8000
#
RUN python ./usr/src/rest_api/manage.py migrate
#
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]
#
# docker run -p 8888:8000 --name dck1 ddrohit/dck1
#

Related

Simple PySpark script using Dockerfile not able to run

So I have a test.py file that creates a dataframe and outputs a csv:
from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
df = spark.createDataFrame([[1,2],[3,4]])
df.write.csv("test", header=True)
I'm trying to get this to run via Docker but with zero luck.
I created the following Dockerfile:
FROM apache/spark-py:v3.3.0
COPY test.py test.py
# RUN python -m pip install --upgrade pip && pip3 install pyspark==3.3.0
RUN apt-get update -y &&\
apt-get install -y python3 &&\
pip3 install pyspark==3.3.0
CMD ["python3", "test.py"]
and run the following to run the test.py script in Docker:
docker build -t ch_image --rm . && docker run --rm --name ch_container ch_image
I'm getting the following error message:
Sending build context to Docker daemon 31.23 kB
Step 1/4 : FROM apache/spark-py:v3.3.0
---> d186e5bd67b6
Step 2/4 : COPY test.py test.py
---> Using cache
---> 460491fa3ac9
Step 3/4 : RUN apt-get update -y && apt-get install -y python3 && pip3 install pyspark==3.3.0
---> Running in 21d6432b8d7b
Reading package lists...
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
The command '/bin/sh -c apt-get update -y && apt-get install -y python3 && pip3 install pyspark==3.3.0' returned a non-zero code: 100
I've tried:
COPY test.py .
CMD ["/opt/spark/bin/pyspark", "test.py"]
RUN python -m pip install --upgrade pip && pip3 install pyspark==3.3.0
Any help to understand why I'm not able to run the script would be much appreciated.
You got "permission denied" error. Could you please add "USER root" between step 2 and step 4 in your dockerfile as shown below?
FROM apache/spark-py:v3.3.0
COPY test.py test.py
USER root
RUN apt-get update -y &&\
apt-get install -y python3 &&\
pip3 install pyspark==3.3.0
CMD ["python3", "test.py"]

Trying to build a docker image but the build fails on Cloud Build

This is the Dockerfile that I am trying to build using Cloud Build.
FROM ubuntu:latest
LABEL MAINTAINER example
WORKDIR /app
RUN apt-get update \
&& apt-get install -y python3-pip python3-dev \
&& pip3 install --upgrade pip
COPY . /app
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
CMD ["newrelic-admin","run-program","gunicorn","wsgi:app","--bind","0.0.0.0:5000","--workers","2","--threads","4","--worker-class=gthread","--log-level","info"]
Here is the requirements.txt file
numpy==1.18.2
pyarrow==0.17.0
lightgbm==2.3.1
scikit-learn==0.22.2.post1
pandas==1.0.3
scipy==1.4.1
Flask==2.1.0
tqdm==4.43.0
joblib==0.15.1
newrelic==6.2.0.156
google-cloud-storage==1.33.0
gunicorn==20.1.0
Once the build begins, it gets stuck at pyarrow and returns
Installing build dependencies: finished with status 'error'
[91m error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
How can I fix this?

Error while building docker image on the server?

I am creating a docker image while building docker it failed to create container on windows and throws the following error. Can anyone help me to overcome this issue
FROM python:3.7
ENV PYTHONUNBUFFERED 1
RUN apt-get update && \
apt-get install -y postgresql-client && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . .
RUN pip install -r requirements.txt
RUN python manage.py makemigrations && python manage.py migrate
EXPOSE 8000
CMD python manage.py runserver 0.0.0.0:8000
Error:
Step 1/9 : FROM python:3.7
---> 0b21994a4758
Step 2/9 : ENV PYTHONUNBUFFERED 1
---> Using cache
---> 925bec50f994
Step 3/9 : RUN apt-get update && apt-get install -y postgresql-client && rm -rf /var/lib/apt/lists/*
Failed to unmarshall layerchain json - invalid character '\x00' looking for beginning of value
The above is the error I am getting. Can anyone help me with this

add-apt-repository fails during docker build

I am trying to get the dordoka/tomcat docker image up and running, but I get this error when running docker build:
Cannot add PPA: 'ppa:~webupd8team/ubuntu/y-ppa-manager'.
ERROR: '~webupd8team' user or team does not exist.
The command '/bin/sh -c apt-get update &&
apt-get install -y software-properties-common &&
add-apt-repository -y ppa:webupd8team/y-ppa-manager &&
add-apt-repository -y ppa:webupd8team/ubuntu/y-ppa-manager &&
apt-get update &&
apt-get install -y git build-essential curl wget software-properties-common'
returned a non-zero code: 1
The command that is failing is add-apt-repository -y ppa:webupd8team/ubuntu/y-ppa-manager. This command runs fine outside of docker. The proxy is configured correctly, as far as I can tell. Any ideas?
#mlowry Is there a particular reason why you have to run this as root?
I assume that when you run it as your user you have also the http_proxy exported ?
In this case you could youse --build-args to pass the http_proxy string.
Quick example:
ubuntu#ip-172-31-10-207:~/test$ docker build --build-arg http_proxy=$http_proxy .
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM alpine:latest
---> e21c333399e0
Step 2/4 : ARG http_proxy
---> Running in fd0832692097
Removing intermediate container fd0832692097
---> 4c58ddefe37c
Step 3/4 : RUN export HTTP_PROXY=$http_proxy
---> Running in 913dc802ea8f
Removing intermediate container 913dc802ea8f
---> 9c3280343c13
Step 4/4 : RUN env
---> Running in 0d078193475a
HOSTNAME=0d078193475a
SHLVL=1
HOME=/root
http_proxy=http://domain\user:pass#proxy.com:8080
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
PWD=/
Removing intermediate container 0d078193475a
---> d4b8996fbb09
Successfully built d4b8996fbb09

docker error Unable to locate package cowsay

When I am running the build command:
$ docker build -t cowsay .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM
Unknown instruction: FROM
dev#ub:~/cowsay$ docker build -t cowsay .
Sending build context to Docker daemon 3.072 kB
Step 1 : FROM ubuntu:14.04
---> 90d5884b1ee0
Step 2 : RUN apt-get -y install cowsay
---> Running in 587aaba2824b
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package cowsay
The command '/bin/sh -c apt-get -y install cowsay' returned a non-zero code: 100
Content of Dockerfile is as follow:
FROM ubuntu:14.04
RUN apt-get -y install cowsay
RUN apt-get -y install fortune
ENTRYPOINT ["/usr/games/cowsay"]
CMD ["Docker is so awesomoooooooo!"]
ONBUILD RUN /usr/games/fortune | /usr/games/cowsay
How can I avoid this error message?
Try and add RUN apt-get update first.
Once the packages are updated, you can install, for instance, cowsay.
See for instance this Dockerfile as an example of RUN apt-get commands:
FROM debian:jessie
RUN apt-get update && apt-get install -y cowsay
COPY docker.cow /usr/share/cowsay/cows/docker.cow
ENTRYPOINT ["/usr/games/cowsay","-f","docker"]
CMD ["moby","dock"]

Resources