Search code examples
phpdockerapachedockerfiledocker-build

Run docker compose build --no-cache return error unix:///.supervisor.sock no such file


Im trying to buld a docker img with php8 and apache, but when restart apache in the line RUN service apache2 restart, return this error , this is dockerfile:

FROM webdevops/php-apache:8.2

# we need libaio!
RUN apt-get update
RUN apt-get install -y libaio1 libaio-dev

ADD instantclient-basic-linux.x64-12.2.0.1.0.zip /tmp/
ADD instantclient-sdk-linux.x64-12.2.0.1.0.zip /tmp/
ADD instantclient-sqlplus-linux.x64-12.2.0.1.0.zip /tmp/
RUN unzip /tmp/instantclient-basic-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sdk-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN unzip /tmp/instantclient-sqlplus-linux.x64-12.2.0.1.0.zip -d /usr/local/
RUN ln -s /usr/local/instantclient_12_2 /usr/local/instantclient
RUN ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so
RUN ln -s /usr/local/instantclient/sqlplus /usr/bin/sqlplus

ENV LD_LIBRARY_PATH /usr/local/instantclient_12_2/

# install
RUN echo 'instantclient,/usr/local/instantclient' | pecl install oci8
RUN echo "extension=oci8" > $(pecl config-get ext_dir)/oci8.ini

# don't know if this is necessary
RUN docker-php-ext-enable oci8
# RUN ldd /usr/local/lib/php/extensions/no-debug-non-zts-20170718/oci8.so
# RUN ldconfig

#restart apache
RUN service apache2 restart

#show if oci8 is present
RUN php -i | grep oci8

# export ports
EXPOSE 80 443

thanks!!

fix the problem and build the docker


Solution

  • In a comment, you cite this line as the problem:

    RUN service apache2 restart
    

    You can safely delete this line.

    A Docker image doesn't include any running processes. Instead, it contains the image's filesystem and some metadata describing what to do when the container starts. If you change a configuration file in a Dockerfile, you don't need to restart the service: it's not running right now, and when you eventually docker run a container from the image, it will start its process for the first time, and that will read the configuration file.

    Since a container only runs a single process, it doesn't generally run any sort of process manager, and so service, systemctl, and similar commands frequently don't work. Your image seems to have a setup where service tries to interact with a supervisord, but again, that's not running during the image build, so RUN service ... fails with the error you show. You shouldn't usually need to run service at all in a Docker context, and it won't typically work.