requirements.txt install error with dockerfile - alabaster path error - docker

Trying to run FastAPI through docker and I am
facing this error while the Dockerfile runs the requirements.txt file
[4/5] RUN pip install -r ./requirements.txt:
#8 1.640 Processing /home/ktietz/src/ci/alabaster_1611921544520/work
#8 1.644 ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: '/home/ktietz/src/ci/alabaster_1611921544520/work'

Related

Can't install supervisor in docker container

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

Unable to execute 'gcc': No such file or directory in Airflow (Docker)

I'm trying to install dbt-core and dbt-redshift in Airflow (Docker) but when I do so I get the error
#9 51.00 unable to execute 'gcc': No such file or directory
#9 51.00 error: command 'gcc' failed with exit status 1
I tried installing gcc with docker build but i still get the same error. My Dockerfile looks like this. Requirements contain dbt-core and dbt-redshift only
FROM python:3.7
RUN apt-get update
RUN apt-get install gcc libc-dev g++ libffi-dev libxml2 libffi-dev unixodbc-dev -y
FROM apache/airflow:2.1.2
COPY requirements.txt /requirements.txt
RUN pip install --no-cache-dir --user -r /requirements.txt
If i build the first command separately it finishes successfully and it looks like gcc gets installed. But then i build the second command and i get the same error again.

pip install: metadata-generation-failed in docker

This is my Dockerfile:
FROM alpine:3.14
# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools
RUN apk add python3-dev # for python3.x installs
RUN apk add musl-dev
RUN apk add gcc
RUN mkdir -p /usr/src/tap-stashstock
RUN mkdir -p /usr/singer
WORKDIR /usr/src/tap-stashstock
ADD . /usr/src/tap-stashstock
ADD singer /usr/singer
RUN pip3 install --upgrade .
This works and then I run docker run -it stashstock-to-bigquery pip3 install target-bigquery which results in this error
Collecting grpcio<2.0dev,>=1.38.1
Downloading grpcio-1.44.0.tar.gz (21.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.4/21.4 MB 3.9 MB/s eta 0:00:00
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [12 lines of output]
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-4wuwnk4b/grpcio_429c1ed72b4244a0a71ac7e9f1ec81c6/setup.py", line 256, in <module>
if check_linker_need_libatomic():
File "/tmp/pip-install-4wuwnk4b/grpcio_429c1ed72b4244a0a71ac7e9f1ec81c6/setup.py", line 203, in check_linker_need_libatomic
cpp_test = subprocess.Popen([cxx, '-x', 'c++', '-std=c++11', '-'],
File "/usr/lib/python3.9/subprocess.py", line 951, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.9/subprocess.py", line 1821, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'c++'
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
What am I missing from my Dockerfile?
This error may for not having a C/C++ compiler.
Try install gcc and build-essensial before pip installation.
Please follow the steps given in
https://github.com/grpc/issues/24556

Dockerfile Permission Denied when using yum install [duplicate]

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"]

docker build failed at 'Downloading mariadb'

Executing 'docker build -t $name .' failed at following issue. It shows 'mariadb_config not found', but i already installed mariadb on this suse15 linux server.
Collecting mariadb==1.0.4
Downloading mariadb-1.0.4.tar.gz (66 kB)
ERROR: Command errored out with exit status 1:
command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-lxx0giq5/mariadb/setup.py'"'"'; __file__='"'"'/tmp/pip-install-lxx0giq5/mariadb/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-hicsuruq
cwd: /tmp/pip-install-lxx0giq5/mariadb/
Complete output (17 lines):
/bin/sh: 1: mariadb_config: not found
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-lxx0giq5/mariadb/setup.py", line 26, in <module>
cfg = get_config(options)
File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 59, in get_config
cc_version = mariadb_config(config_prg, "cc_version")
File "/tmp/pip-install-lxx0giq5/mariadb/mariadb_posix.py", line 29, in mariadb_config
"mariadb_config not found.\n\nPlease make sure, that MariaDB Connector/C is installed on your system.\n"
OSError: mariadb_config not found.
Please make sure, that MariaDB Connector/C is installed on your system.
Either set the environment variable MARIADB_CONFIG or edit the configuration
file 'site.cfg' and set the 'mariadb_config option, which should point
to the mariadb_config utility.
The MariaDB Download website at <https://downloads.mariadb.com/Connectors/c/>
provides latest stable releease of Connector/C.
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The command '/bin/sh -c pip3 install -r requirements.txt' returned a non-zero code: 1
And related Dockerfile content is as follows.
FROM python:3.6.5
WORKDIR /slic-scripts
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY . .
CMD ["python3", "/slic-scripts/run_cmd.sh"]
As #Jonathan Jacobson wrote, you need to have the MariaDB Connector installed in your Docker image before proceeding with pip install.
Since python:3.6.5 is based on debian stretch, the connector offered there is 2.3.2 which is not supported by the mariadb module (as stated in the prerequisites). To fix this, you might want to switch to a different image (e.g. 3.6-buster).
Here's a working test:
FROM python:3.6-buster
RUN apt-get update \
&& apt-get -yy install libmariadb-dev
WORKDIR /slic-scripts
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip3 install -r requirements.txt
COPY . .
CMD ["python3", "/slic-scripts/run_cmd.sh"]
You need to install MariaDB Connector/C inside the Dockerfile, before running pip3 install. It doesn't help that you installed it on your host.
Install MariaDB Connector/C using the below command, which is a dependency.
sudo apt-get install libmariadb3 libmariadb-dev
RUN pip3 install -r requirements.txt

Resources