<p>As per <a href="https://docs.docker.com/compose/env-file/" rel="nofollow noreferrer">docker docs</a>, environment variables in .env file expected to be in in key-val format as <code>VAR=VAL</code> which works fine for sample like <code>foo=bar</code> but no mention of unavoidable special characters e.g. '=', which may confuse for <code>key-val</code> separator OR <code>space</code> both part of valid db connection string as in:</p>

<p>secrets.env file:</p>

<pre><code> connectionString=Data Source=some-server;Initial Catalog=db;User ID=uid;Password=secretpassword
</code></pre>

<p>which is referred in docker-compose.debug.yaml file content as:</p>

<pre><code>services:
  some-service:
    container_name: "service-name"
    env_file:
      - secrets.env
    ports:
      - "80:80"
</code></pre>

<p>Which is further used to transform into <code>docker-compose.yaml</code> as shown complete flow below:</p>

<p><a href="https://i.stack.imgur.com/yplMb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yplMb.png" alt="enter image description here"></a></p>

<p>So the question is - how do you include connection string which has <code>=</code> and <code>Spaces</code> as part of value ?</p>

<p><strong>Need</strong> - We have few  micro-services within VS solution and looking forward to avoid repetition of same connection strings otherwise needs in service spec of `docker-compose.yaml'  </p>

<p><strong>Tried</strong> including values in single/double quote but post transformation whatever after <code>=</code> is treated as value including quotes just similar like kubernets yaml file convention</p>

AnilR
<p>I ran a test without any issues:</p>

<pre><code>$ cat .env
ENV=default
USER_NAME=test2
SPECIAL=field=with=equals;and;semi-colons

$ cat docker-compose.env.yml
version: '2'

services:
  test:
    image: busybox
    command: env
    environment:
      - SPECIAL

$ docker-compose -f docker-compose.env.yml up
Creating network "test_default" with the default driver
Creating test_test_1_55eac1c3767c ... done
Attaching to test_test_1_d7787ac5bfc0
test_1_d7787ac5bfc0 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
test_1_d7787ac5bfc0 | HOSTNAME=d249a16a8e09
test_1_d7787ac5bfc0 | SPECIAL=field=with=equals;and;semi-colons
test_1_d7787ac5bfc0 | HOME=/root
test_test_1_d7787ac5bfc0 exited with code 0
</code></pre>
