<p>We are trying some docker containers locally. For security purposes, user and password are used as env variables in the config file. The config file is copied as the volume in the docker-compose for one of the APIs. After docker-compose up,  inside the container, we are still seeing the variable name and not the env variable value.</p>
<p>Config file inside the container copied as volume:</p>
<p>dbconfig:</p>
<pre><code>dbuser: ${USER}
dbpass: ${PASSWORD}
dbname: 
dbdrivername: 
tablename
</code></pre>
<p>docker-compose.yaml:</p>
<p>services:</p>
<pre><code>api:
    image: ${API_IMAGE:api}:${VERSION:-latest}
    ports:
        - 8080:8080
    environment:
     - &quot;USER=${USER}&quot;
     - &quot;PASSWORD=${PASSWORD}&quot;
    volumes:
        - ./conf/config.yaml:/etc/api.yaml
    command: [&quot;-config&quot;, &quot;/etc/api.yaml&quot;]
</code></pre>
<p>Config.yaml:</p>
<p>dbconfig:</p>
<pre><code>dbuser: ${USER}
dbpass: ${PASSWORD}
dbname: 
dbdrivername: 
tablename
</code></pre>
<p>Please help us get rid of this error as we are newly adopting docker testing</p>

Raji M
<p>Issue fixed with the solution mentioned here. <a href="https://stackoverflow.com/questions/71916469/how-to-run-2-different-commands-from-docker-compose-command">How to run 2 different commands from docker-compose command:</a>
We added the sed command in the entry point script which searches for the env variable inside the config and replaces it with the value. Env variables are passed from docker-compose for the service</p>
<pre><code>sed \ 
-e &quot;s/USER/${USER}/g&quot; \
 -e &quot;s/PASSWORD/${PASSWORD}/g&quot; \ -i /etc/api.yaml
</code></pre>
