docker-compose.exe
behaves as it did in Docker Desktop for Windows 2.1.0.5.
If terminal code page is UTF-8, docker-compose exec
fails with LookupError: unknown encoding: cp65001
If .env file contains any entries, docker-compose exec
fails with TypeError: environment can only contain strings
The bundled docker-compose.exe
appears to have been compiled using Python 2.7 and an older version of python-dotenv.
The issue can be worked around by installing docker-compose via pip and Python 3
Add docker-compose.yml
:
version: "3"
services:
test:
image: ubuntu
command: tail -f /dev/null
Add .env
:
A=
In powershell, run:
$OutputEncoding = `
[Console]::OutputEncoding = `
[Console]::InputEncoding = [Text.Encoding]::UTF8
chcp.com 65001
docker-compose down
docker-compose up -d test
docker-compose exec test echo 1
Observe unexpected error:
Traceback (most recent call last):
File "logging\__init__.py", line 879, in emit
File "site-packages\colorama\ansitowin32.py", line 41, in write
File "site-packages\colorama\ansitowin32.py", line 162, in write
File "site-packages\colorama\ansitowin32.py", line 187, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
LookupError: unknown encoding: cp65001
Logged from file main.py, line 78
Switch codepage to Windows 1252 and try again:
$OutputEncoding = `
[Console]::OutputEncoding = `
[Console]::InputEncoding = [Text.Encoding]::GetEncoding(1252)
chcp 1252
docker-compose exec test echo 1
Observe error:
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
[8940] Failed to execute script docker-compose
Remove .env
and try again:
rm .env
docker-compose down
docker-compose up -d test
docker-compose exec test echo 1
Observe expected output: 1
@gurutech-thomasr thanks for the report and the detailed repro instructions. It fails as you describe on my local machine too.
docker-compose.exe --version (WSL Windows 10)
Traceback (most recent call last):
File "docker-compose", line 6, in
File "compose\cli\main.py", line 71, in main
File "compose\cli\main.py", line 103, in dispatch
File "compose\cli\docopt_command.py", line 25, in parse
File "compose\cli\docopt_command.py", line 12, in docopt_full_help
File "site-packages\docopt.py", line 575, in docopt
File "site-packages\docopt.py", line 484, in extras
File "site-packages\colorama\ansitowin32.py", line 41, in write
File "site-packages\colorama\ansitowin32.py", line 162, in write
File "site-packages\colorama\ansitowin32.py", line 190, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
LookupError: unknown encoding: cp0
[2456] Failed to execute script docker-compose
In the meantime while waiting a fix, please check out workaround here https://github.com/docker/compose/issues/7169#issuecomment-576987766
Same here:
Traceback (most recent call last):
File "docker-compose", line 6, in <module>
File "compose\cli\main.py", line 71, in main
File "compose\cli\main.py", line 103, in dispatch
File "compose\cli\docopt_command.py", line 25, in parse
File "compose\cli\docopt_command.py", line 12, in docopt_full_help
File "site-packages\docopt.py", line 575, in docopt
File "site-packages\docopt.py", line 484, in extras
File "site-packages\colorama\ansitowin32.py", line 41, in write
File "site-packages\colorama\ansitowin32.py", line 162, in write
File "site-packages\colorama\ansitowin32.py", line 190, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
LookupError: unknown encoding: cp65001
[18308] Failed to execute script docker-compose
I'm also experiencing this and getting the following output repeatedly:
Traceback (most recent call last):
File "logging\__init__.py", line 879, in emit
File "site-packages\colorama\ansitowin32.py", line 41, in write
File "site-packages\colorama\ansitowin32.py", line 162, in write
File "site-packages\colorama\ansitowin32.py", line 190, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
LookupError: unknown encoding: cp65001
Logged from file service.py, line 578
Same here since last update:
docker-compose version
Traceback (most recent call last):
File "docker-compose", line 6, in
File "compose\cli\main.py", line 72, in main
File "compose\cli\main.py", line 117, in perform_command
File "compose\cli\main.py", line 1134, in version
File "site-packages\colorama\ansitowin32.py", line 41, in write
File "site-packages\colorama\ansitowin32.py", line 162, in write
File "site-packages\colorama\ansitowin32.py", line 190, in write_and_convert
File "site-packages\colorama\ansitowin32.py", line 195, in write_plain_text
LookupError: unknown encoding: cp65001
[19344] Failed to execute script docker-compose
my workaround is chcp 437
before docker-compose
on 2.2.0.
Just using Git Bash fixes it too.
Just using Git Bash fixes it too.
does not work for me.
In case it gets buried, I worked around the issue by installing docker-compose via python 3.8 and pip:
> where.exe docker-compose.exe; docker-compose version
C:\Program Files\Docker\resources\bin\docker-compose.exe
docker-compose version 1.25.2, build 698e2846
docker-py version: 4.1.0
CPython version: 2.7.16
OpenSSL version: OpenSSL 1.0.2q 20 Nov 2018
> $env:path = "C:\bin\python\38;C:\bin\python\38\Scripts;${env:path}"
> pip --version; pip install docker-compose
pip 20.0.1 from c:\bin\python\38\lib\site-packages\pip (python 3.8)
> where.exe docker-compose.exe; docker-compose version
C:\bin\Python\38\Scripts\docker-compose.exe
C:\Program Files\Docker\resources\bin\docker-compose.exe
docker-compose version 1.25.2, build unknown
docker-py version: 4.1.0
CPython version: 3.8.1
OpenSSL version: OpenSSL 1.1.1d 10 Sep 2019
The important bit is to ensure that the PATH environment variable prefers pip-installed docker-compose over the one installed with Docker Desktop for Windows.
Again, I suspect these related issues may be due to Docker Desktop for Windows bundling a docker-compose built for Python 2.7
Fixed by https://github.com/docker/compose/pull/7183
You can find a new release with the fix at https://github.com/docker/compose/releases/tag/1.25.3
When can we expect an update to Docker Desktop with updated Docker Compose? Is there a recommended method of updating Docker Compose in Windows without janky hacks like copying over the top of the exe?
Fixed by #7183
You can find a new release with the fix at https://github.com/docker/compose/releases/tag/1.25.3
I can confirm that docker-compose 1.25.3 fixed the problem. I worked around it by cinst -y docker-compose
and making sure the chocolatey shims are placed before Docker-Desktop in PATH
, .i.e.
C:\ProgramData\chocolatey\bin
beforeC:\Program Files\Docker\Docker\resources\bin
I ensured that the Chocolatey path was listed before the actual Docker installation and also ensured that I had installed the latest version. Unfortunately, the error still occurs.
PS E:\cloud.ingwie.io\Work\Maria\elch-flohmarkt.laradock> docker-compose --version
docker-compose version 1.25.2, build 698e2846
PS E:\cloud.ingwie.io\Work\Maria\elch-flohmarkt.laradock> docker-compose exec workspace bash
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
[26840] Failed to execute script docker-compose
Any other idea?
@IngwiePhoenix Read above:
docker-compose 1.25.3 fixed the problem
Most helpful comment
When can we expect an update to Docker Desktop with updated Docker Compose? Is there a recommended method of updating Docker Compose in Windows without janky hacks like copying over the top of the exe?