Docker Community Forums

Share and learn in the Docker community.

Adapting Compose file to use images pushed to Docker Hub or other repo

I have a Docker Compose file that builds multiple containers using the .yml file and DockerFile and other resources. This is not complete, but just an example.

Part of .yml:

    build: php-fpm-nginx
    depends_on: [pacs-1,mysql_db]
    restart: unless-stopped
    ports: ["443:443"]
       - ./nginx-home:/nginx-home      # NGINX web directories
       - ./nginx-logs:/var/log/nginx   # NGINX log directory
       - ./tls:/etc/nginx/tls          # NGINX ssl certs path
       - ./php-fpm-nginx/default.conf:/etc/nginx/conf.d/default.conf

Part of DockerFile:

FROM php:8.0-fpm # upgrade to 8
ENV DEBIAN_FRONTEND=noninteractive
# Install dependencies, libssl1.1-dev ?
RUN apt-get update && apt-get install -y \
    xvfb \
    wget \
    openssl \
    xorg \
    libssl1.1 \
    build-essential \
    libpng-dev \
    libjpeg62-turbo-dev \
    libfreetype6-dev \
    locales \
    zip \
    jpegoptim optipng pngquant gifsicle \
    vim \
    unzip \
    git \
    curl \
    libzip-dev \
    dcmtk \
    nginx \
    supervisor \
    libpq-dev \
    geoip-database \
# Install wkhtmltopdf
RUN wget
RUN tar xvJf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
RUN cp wkhtmltox/bin/wkhtmlto* /usr/bin/
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
COPY php.ini /usr/local/etc/php/php.ini
COPY mime.types /etc/nginx/mime.types

# adjustments to php.ini base on the production version.
# application/wasm  wasm is missing from distro.

# Install extensions and configure

RUN docker-php-ext-configure gd --with-freetype --with-jpeg
RUN docker-php-ext-configure zip
RUN docker-php-ext-install pdo_mysql zip exif pcntl gd sockets
# Install Postgre PDO
RUN docker-php-ext-configure pgsql -with-pgsql=/usr/local/pgsql
RUN docker-php-ext-install pdo pdo_pgsql pgsql

# RUN sed -E -i -e 's/max_execution_time = 1200/max_execution_time = 120/' /etc/php.ini \
#  && sed -E -i -e 's/memory_limit = 128M/memory_limit = 512M/' /etc/php.ini \
#  && sed -E -i -e 's/post_max_size = 8M/post_max_size = 64M/' /etc/php.ini \
#  && sed -E -i -e 's/upload_max_filesize = 2M/upload_max_filesize = 64M/' /etc/php.ini

# php artisan storage:link 
# THAT NEEDS TO BE RUN FROM THE nginx-home/LaravelPortal/ directory to symlink the storage directory, done in
# sudo docker exec -it  orthanc-docker-dev_ris_php-fpm_1 /bin/bash
# COPY default.conf /etc/nginx/conf.d/default.conf
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
ENTRYPOINT ["/bin/bash","/"]
# Can be run in entrypoint also:  ln -sfn /nginx-home/PortalRads/storage/app/public/ /nginx-home/PortalRads/public/storage

There are others that are similar, but they pull another “mainline” image that is updated periodically. What I want to do is re-use my built images along with an abbreviated form of the .yml file. Not sure that is possible. In my example, is it as simple as pushing my built image to a repo, like Docker Hub, and then in the DockerFile use:

FROM php-fpm-nginx (e.g.) instead of build, where php-fpm-nginx is my built image ?

Also, with this particular container it takes a very long time to start up nginx and fpm when I am using Docker Desktop for Mac OS Catalina. Takes maybe 5-10 minutes to start up, but runs relatively fast after that. All of my other containers (e.g. postgres, mysql and another custom server) all start up immediately. Wondering if it
has something to do with volume / folder mapping since the nginx-home directory on the host has a lot of files.