title: Best way for Docker post run provisioning
body: <p>I am quite new to Docker, and I am trying to find which is the best way for Docker provisioning after my container is up.
  We use the <code>docker-compose</code> file to make our container up and our compose file looks like this.</p>
  
  <pre><code>version: "3"
  
    php:
      image: wodby/drupal-php:$PHP_TAG
      container_name: "${PROJECT_NAME}_php"
      environment:   
        DB_HOST: $DB_HOST
        DB_PORT: $DB_PORT
        DB_USER: $DB_USER
        DB_PASSWORD: $DB_PASSWORD
        DB_NAME: $DB_NAME
        DB_DRIVER: $DB_DRIVER
        PHP_FPM_USER: wodby
        PHP_FPM_GROUP: wodby
        COLUMNS: 80 # Set 80 columns for docker exec -it.
      volumes:
        - ./Insider:/var/www/html
  
    nginx:
      image: wodby/nginx:$NGINX_TAG
      container_name: "${PROJECT_NAME}_nginx"
      depends_on:
        - php
      environment:
        NGINX_STATIC_OPEN_FILE_CACHE: "off"
        NGINX_ERROR_LOG_LEVEL: debug
        NGINX_BACKEND_HOST: php
        NGINX_SERVER_ROOT: /var/www/html/web
        NGINX_VHOST_PRESET: $NGINX_VHOST_PRESET
      ports:
        - '8000:80'
      volumes:
        - ./Insider:/var/www/html
  </code></pre>
  
  <p>Now we need to perform some setup tasks once <code>PHP</code> container is up. Now I need some idea on what is the best way to perform provisioning in this container. We have 2 ideas and they are as follows.</p>
  
  <ol>
  <li>Write a shell script and put it as one of the tasks in our build process. </li>
  <li>Use ansible and connect from a different server to do the provision.</li>
  </ol>
  
  <p>but the ideal process would be, if we can somehow include a shell script in PHP container from our <code>docker-compose.yml</code> file and when we would run <code>docker-compose up -d</code> it should run as part of that container up process and make everything ready, so we do not need to go through 2nd command/process and so on.</p>