title: Starting NginX with my modified nginx.conf on ECS
body: <p>I have an environment in AWS with an ECS cluster, an EFS source and some services running on this cluster.</p>
  
  <p>One of my services is the NginX web server which I use to serve our site and our services. As a solution to keep some sensitive and static configuration files we have chosen the EFS service. So, each service creates a volume from this EFS and mount it every time a container starts.</p>
  
  <p>The problem is with NginX. I want to store my nginx.conf file into an EFS folder and after the NginX service starts, we want the container to copy this file at <code>/etc/nginx/</code> folder in order for my NginX server to start with my configuration. </p>
  
  <ol>
  <li>I've tried to build my own image including my configuration with success but this is not what we want.That means that we should build a new image every time we want to change a line on nginx.conf.</li>
  <li>I've tried to create a script to run every time the container starts and copy my configuration but i didn't manage to make it play on ECS. Either the NginX failed to reload, either the syntax is wrong, either the file is not available.</li>
  </ol>
  
  <blockquote>
  <pre><code>#!/bin/bash
  cp /efs/nginx.conf /etc/nginx/
  nginx -s reload
  </code></pre>
  </blockquote>
  
  <ol start="3">
  <li>Ι considered to find out how to create a cron job to run every X minutes and copy my nginx.conf to etc/nginx but this seems to be a stupid approach.</li>
  <li>I made like 60 different task definitions revisions in order to find out how this CMD Environment option works on ECS. Of course the most of them has to do with the syntax and i get bach errors like "invalid option: bash" or "invalid option: /tmp/1.sh" etc</li>
  </ol>
  
  <p>Samples:</p>
  
  <p>1.Command <code>["cp","/efs/nginx.conf /etc/nginx/"]</code></p>
  
  <p>2.Entry point <code>["nginx","-g","daemon off;"]</code>
    Command <code>["cp /efs/nginx.conf /etc/nginx/"]</code></p>
  
  <ol start="3">
  <li><p>Entry point: <code>["nginx","-g","daemon off"]</code>
  Command: <code>["/bin/sh","cp","/efs/nginx.conf/","/etc/nginx/"]</code></p></li>
  <li><p>Command <code>["[\"cp\"","\"/efs/nginx.conf\"","\"/etc/nginx/\"]","[\"nginx\"","\"-g\"","\"daemon off;\"]"]</code></p></li>
  <li><p>Command <code>["cp /efs/nginx.conf /etc/nginx/","nginx -g daemon off;"]</code></p></li>
  <li><p>Command <code>["cp","/efs/nginx.conf /etc/nginx/","nginx -g daemon off;"]</code></p></li>
  </ol>
  
  <p>-</p>
  
  <p>Does anyone knows or does anyone already implement this solution on ECS?
  To replace /etc/nginx/nginx.conf with a modified one from a binded volume?</p>
  
  <p>Thanks in advance</p>