Home > database >  Can't install supervisor in docker container
Can't install supervisor in docker container

Time:01-29

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

CodePudding user response:

It appears that the CentOS 7 virtual machine's default package repository does not contain the package supervisor. You can either manually install supervisor by downloading the required packages and files, or you can try using an alternate repository that has the package.

Here is an example of how to manually install supervisor:

  1. The most recent version of Supervisor can be downloaded from the official website:
wget https://github.com/Supervisor/supervisor/archive/4.2.0.tar.gz

  1. Decompress the archive:
tar -xzvf 4.2.0.tar.gz
  1. Access the extracted directory now:
cd supervisor-4.2.0

  1. Install the needed software packages:
yum install python3-setuptools

  1. Using pip3, install supervisor:
pip3 install .
  1. Create the supervisor configuration files that are required:
mkdir /etc/supervisor
mkdir /var/log/supervisor

  1. In the file /etc/supervisor/supervisord.conf, add the following text:
[unix_http_server]
file=/var/run/supervisor.sock

[supervisord]
logfile=/var/log/supervisor/supervisord.log
pidfile=/var/run/supervisord.pid

[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface

[supervisorctl]
serverurl=unix:///var/run/supervisor.sock

  1. Start the supervisor:
supervisord

  1. Verify the supervisor's status:
supervisorctl status

Supervisor ought to be usable in the container at this point.

  • Related