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"]
Related
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
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?
My Dockerfile looks like this:
FROM ubuntu:20.04
RUN apt update
RUN apt install -y libpq-dev python3-dev python3-pip
ENTRYPOINT /APP
RUN mkdir -p /APP/OUTPUT
COPY . .
RUN pip3 install -r requirements.txt
CMD ["python3" "Main.py"]
But when i run the container, i get the following message:
/bin/sh: 1: /APP: Permission denied in Ubuntu Docker container
What am i doing wrong?
I have a docker compose file which sets up a service with a GitHub URL for the context. The service's Dockerfile copies a requirements.txt and installs it. That works OK (COPY requirements.txt /rasa_traind/). But when I change that line to COPY . <dir> I get a COPY failed: file not found in build context error.
Docker Compose
chatbot_server:
build:
context: <GitHub URL>
dockerfile: Dockerfile
ports:
- "5005:5005"
depends_on:
- rasa_actions_server
- redis
extra_hosts:
- "host.docker.internal:host-gateway" # for docker.host.internal to work on Linux
docker-compose build
Step 4/8 : RUN pip install --upgrade pip
---> Using cache
---> 5a584d36ea77
Step 5/8 : COPY . /rasa_traind/
ERROR: Service 'chatbot_server' failed to build: COPY failed: file not found in build context or excluded by .dockerignore: stat rasa_traind/: file does not exist
Dockerfile
FROM python:3.8.12-slim-buster
RUN apt-get update
RUN yes | apt-get install python3-dev build-essential
RUN pip install --upgrade pip
# COPY requirements.txt /rasa_traind/ # Works
COPY . /rasa_traind/
RUN pip install -r requirements.txt
WORKDIR /rasa_traind/rasa_actions_server/
CMD ["rasa", "run"]
Have you tried setting the WORKDIR before COPY . /rasa_traind/. Something like this
FROM python:3.8.12-slim-buster
RUN apt-get update
RUN yes | apt-get install python3-dev build-essential
RUN pip install --upgrade pip
WORKDIR /rasa_traind/rasa_actions_server/
# COPY requirements.txt /rasa_traind/ # Works
COPY . /rasa_traind/
RUN pip install -r requirements.txt
CMD ["rasa", "run"]
This is my first Dockerfile and this is what I have so far.
FROM python:3.6-stretch
# install build utilities
RUN apt-get update && \
apt-get install -y gcc make apt-transport-https ca-certificates build-essential
# check our python environment
RUN python3 --version
RUN pip3 --version
# set the working directory for containers
WORKDIR /usr/src/toxic-content-monitoring
# Installing python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy all the files from the project’s root to the working directory
COPY src/ /src/
RUN ls -la /src/*
# Running Python Application
CMD ["python3", "/src/main.py"]
But when I am trying to run the docker image the files inside the data folder cannot be found.
Here is a picture of the my project structure.
Changed it to what was suggested and still getting an error.
FROM python:3.6-stretch
# install build utilities
RUN apt-get update && \
apt-get install -y gcc make apt-transport-https ca-certificates build-essential
# check our python environment
RUN python3 --version
RUN pip3 --version
# set the working directory for containers
WORKDIR /usr/src/toxic-content-monitoring
# Installing python dependencies
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# Copy all the files from the project’s root to the working directory
COPY src/ /src/
COPY data /data/
RUN ls -la /src/*
# Running Python Application
CMD ["python3", "/src/main.py"]
This is the error message.
docker run toxic-content-monitoring:0.1
wiki.en.vec: 6.60GB [10:05, 10.9MB/s]
0%| | 0/2519371 [00:00<?, ?it/s]Skipping token 2519370 with 1-dimensional vector ['300']; likely a header
100%|██████████| 2519371/2519371 [08:36<00:00, 4878.67it/s]
Traceback (most recent call last):
File "/src/main.py", line 11, in <module>
from preprocessor import normalize_comment, clean_text
File "/src/preprocessor.py", line 42, in <module>
word_file = open(link, "r")
FileNotFoundError: [Errno 2] No such file or directory: 'data/identity_hateWordFile.txt'
I believe your Dockerfile is missing COPY data/ /data/ command in it. You are only doing a copy of src folder and not data. Please include COPY data /data/ right after COPY src/ /src/ line in your Dockerfile and give it a try.