Compose: TypeError: environment can only contain strings

Created on 21 Jan 2020  路  8Comments  路  Source: docker/compose


  • [v ] I have tried with the latest version of my channel (Stable or Edge)
  • [v ] I have uploaded Diagnostics
  • Diagnostics ID: D5D0C2E5-E342-42A4-BA6B-1174744BA405/20200121213746

Expected behavior

Work correctly

Actual behavior

$ docker-compose exec app sh
Traceback (most recent call last):
  File "docker-compose", line 6, in <module>
  File "compose\cli\main.py", line 72, in main
  File "compose\cli\main.py", line 128, in perform_command
  File "compose\cli\main.py", line 491, in exec_command
  File "compose\cli\main.py", line 1469, in call_docker
  File "subprocess.py", line 172, in call
  File "subprocess.py", line 394, in __init__
  File "subprocess.py", line 644, in _execute_child
TypeError: environment can only contain strings
[9644] Failed to execute script docker-compose

Information

  • Windows Version: 10 Pro
  • Docker Desktop Version: 2.2.0.0 (42247) stable
  • Steps to reproduce the behavior

    version: "3"
    
    services:
      app:
        build: docker/php
        volumes:
          - ./:/app
        env_file:
          - .env
    
    1. Empty .env file. Run docker-compose exec app sh - work correctly
    2. Add data to .env file. For example:
    APP_ENV=development
    
    1. Run docker-compose exec app sh - error: environment can only contain strings

    Most helpful comment

    For now, I have solved it accessing the bash through the Cli on the windows-docker application:
    image

    I hope it helps you too.

    All 8 comments

    For now, I have solved it accessing the bash through the Cli on the windows-docker application:
    image

    I hope it helps you too.

    A workaround that was working for me was to run the command using --log-level=DEBUG. Now before the error message a line is printed like
    'C:\Program Files\Docker\Docker\Resources\bin\docker.exe' start --attach --interactive ab554a8aa626929dba218571606f6379e9b87edc11ac4311a94f4b3752a4b79f
    when copy pasted back into the terminal this works as expected.

    I have the same issue. I am able to run docker exec -ti app sh instead of using docker-compose for now.

    I also have the described issue.

    Removing only the comments from my .env file did not do the trick. Also I tried to change the encoding to UTF8-with-BOM, no luck either.

    Workaround: If I transfer the contents of the .env file into environment section of docker-compose.yml file and clear the .env file it works (which leaves me with uncommited changes though).

    Solution reported by @ulyssessouza seems work for me! Thanks!

    First of all I can confirm that the version 1.25.3 fix the problem. And it is also nice that there is allready a solutuion for that problem.

    What I totaly don't get is how it is delivred. I Installed the desktop app today and run straight into that problem. That I had to spend a lot of time on a bug that is already fixed. Where is the point on not deliver the newest version and don't give a option to update it on the app it self? The app only installs 1.25.2 right now and tell you all is up to date.

    @BenjaminQuandt an workaround for the update problem would be to get the .exe from the release page ( https://github.com/docker/compose/releases/tag/1.25.4 for example ), rename it to docker-compose.exe and put it in the docker executables path ( Docker\Docker\resources\bin ). Would recommend doing an backup to the old docker-compose executable.

    Was this page helpful?
    0 / 5 - 0 ratings