title: How to debug entrypoint of Dockerfile?
body: <p>I try to run laravel in docker with external mysql. In <em>docker-compose.yml</em> I use <code>depends_on</code> for db. <em>entrypoint.sh</em> works perfectly with <code>exec</code>, but in <em>Dockerfile</em> <code>ENTRYPOINT[&quot;/etc/entrypoint.sh&quot;]</code> does nothing.</p>
  <p>My <em>Dockefile</em></p>
  <pre><code>FROM php:7.4-fpm as build-stage
  
  WORKDIR /app
  
  RUN apt-get update &amp;&amp; apt-get install -y nginx &amp;&amp; apt-get install -y redis-server &amp;&amp; apt install -y nodejs &amp;&amp; apt install -y npm &amp;&amp; apt-get install -y \
      libonig-dev libpq-dev \
      build-essential \
      libzip-dev \
      libpng-dev \
      libjpeg62-turbo-dev \
      libwebp-dev libjpeg62-turbo-dev libpng-dev libxpm-dev \
      libfreetype6 \
      libfreetype6-dev \
      locales \
      zip \
      jpegoptim optipng pngquant gifsicle \
      vim \
      unzip \
      git \
      curl
  
  RUN apt-get clean &amp;&amp; rm -rf /var/lib/apt/lists/*
  
  RUN docker-php-ext-install pdo pdo_mysql mysqli mbstring zip exif pcntl
  
  COPY ./nginx.conf /etc/nginx/conf.d/app.conf
  
  COPY . /app
  
  COPY nginx.conf /etc/nginx/sites-enabled/default
  COPY entrypoint.sh /etc/entrypoint.sh
  
  RUN chmod +x /etc/entrypoint.sh
  
  RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
  
  RUN cd /app &amp;&amp; mkdir storage storage/framework &amp;&amp; cd storage/framework &amp;&amp; mkdir sessions views cache logs
  
  RUN chmod -R 777 /app/storage/
  RUN chmod -R 777 /app/public/images/
  RUN mkdir -p /app/public/docs &amp;&amp; chmod -R 777 /app/public/docs/
  
  RUN cd /app &amp;&amp; composer install
  
  EXPOSE 80 443
  
  ENTRYPOINT [&quot;/etc/entrypoint.sh&quot;]
  </code></pre>
  <p><em>docker-compose.yml</em></p>
  <pre><code>version: '3.2'
  
  services:
    db:
      image: mysql:8
      restart: always
      container_name: laravel_db
      env_file:
        - .env
      ports:
        - &quot;3307:3306&quot;
      environment:
        MYSQL_DATABASE: db
        MYSQL_ROOT_PASSWORD: pass
        MYSQL_ROOT_HOST: '%'
      volumes:
        - ./public/docs/:/app/public/docs/
        - ./public/images/:/app/public/images/
        - ./mysql.cnf:/etc/mysql/conf.d/mysql.cnf
        - /var/lib/mysql/:/var/lib/mysql/
  
    app:
      build:
        context: .
        dockerfile: Dockerfile
      container_name: laravel_api
      restart: always
      volumes:
        - ./.env:/app/.env
      depends_on:
        - db
      env_file:
        - .env
      ports:
        - &quot;9000:80&quot;
  </code></pre>
  <p><em>entrypoint.sh</em></p>
  <pre><code>#!/usr/bin/env bash
  service nginx start
  service mysql start
  php-fpm
  service redis-server start
  
  cd /app &amp;&amp; php artisan migrate --force
  cd /app &amp;&amp; php artisan key:generate --force
  cd /app &amp;&amp; /usr/bin/npm install laravel-echo-server
  cd /app &amp;&amp; /usr/bin/npm install pm2
  cd /app &amp;&amp; /app/node_modules/pm2/bin/pm2 start laravel-echo-server.js
  cd /app &amp;&amp; php artisan passport:install
  </code></pre>
  <p>The below works. <em>entrypoint.sh</em> is executed</p>
  <pre><code>sudo docker-compose build --no-cache &amp;&amp; sudo docker-compose up -d &amp;&amp; sudo docker exec -it `sudo docker ps -q --filter ancestor=laravel-docker_app` /bin/bash -c '/etc/entrypoint.sh'
  </code></pre>
  <p>The below does not work. <em>entrypoint.sh</em> is not executed</p>
  <pre><code>sudo docker-compose build --no-cache &amp;&amp; sudo docker-compose up -d
  </code></pre>
  <p>How I can debug it?</p>