I have a Dockerfile
FROM python:3.10.4
RUN apt-get update
RUN apt-get install -y supervisor
WORKDIR /app
COPY requirements.txt .
COPY ./docker/api/conf.d/supervisor.conf /etc/supervisor/conf.d/supervisord.conf
RUN pip3 install -r requirements.txt
EXPOSE 8010
CMD ["uvicorn", "v1.api:app", "--host=0.0.0.0", "--port", "8010", "--reload"]
When I build this Dockerfile on my local machine (Ubuntu), everything works fine
However, when I build it on a CentOS 7 virtual machine, i got this error:
=> ERROR [3/7] RUN apt-get install -y supervisor
0.6s
[3/7] RUN apt-get install -y supervisor:
#0 0.473 Reading package lists...
#0 0.501 Building dependency tree...
#0 0.503 Reading state information...
#0 0.508 E: Unable to locate package supervisor
failed to solve: executor failed running [/bin/sh -c apt-get install -y supervisor]: exit code: 100
Please help me.
How do I install supervisor in the container
Related
FROM ubuntu:focal
WORKDIR /admin-flask
COPY . /admin-flask
# set environment variables
# ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
ENV FLASK_APP run.py
VOLUME . /var/wwww
RUN apt update -y && apt upgrade -y
RUN apt autoremove -y
RUN apt install python3 -y && apt install python3-pip -y
RUN pip install virtualenv
RUN virtualenv env
RUN chmod +x run.py
# install python dependencies
RUN /admin-flask/env/bin/pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
# gunicorn
#CMD ["gunicorn", "--config", "gunicorn-cfg.py", "run:app"]
CMD ["/admin-flask/env/bin/gunicorn","--config", "gunicorn-cfg.py", "run.py"]
failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container
init: open /dev/ptmx: no such file or directory: unknown.
ERRO[0004] error waiting for container:
Trying to build a local Docker file, getting this error when running a container
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"]
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?
This question already has an answer here:
Can't use yum inside Docker container running on CentOS
(1 answer)
Closed 2 years ago.
I'm trying to create Dockerfile from this Image: https://hub.docker.com/r/centos/python-27-centos7
My Dockerfile:
FROM centos/python-27-centos7:latest
RUN yum install rpm-build -y
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
CMD ["bash"]
But I got next error:
=> ERROR [2/9] RUN yum install rpm-build -y 0.6s
------
> [2/9] RUN yum install rpm-build -y:
#5 0.480 Loaded plugins: fastestmirror, ovl
#5 0.485 ovl: Error while doing RPMdb copy-up:
#5 0.485 [Errno 13] Permission denied: '/var/lib/rpm/Dirnames'
#5 0.579 You need to be root to perform this command.
------
I tried add sudo but still doesn't work.
What is wrong here?
Try to use the user root
FROM centos/python-27-centos7:latest
USER root
RUN yum install rpm-build -y
WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
CMD ["bash"]
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"]