Starting Docker compose with Django: UnicodeDecodeError

I’m just starting with Docker and Django. I try to create example Django project as here: https://docs.docker.com/compose/django

I made Dockerfile, requirements.txt and docker-compose.yml. But when I try to create the Django project using the docker-compose command, I have an error:

docker-compose run web django-admin.py startproject MyProject .
Traceback (most recent call last):
File "docker-compose", line 3, in <module>
File "compose\cli\main.py", line 64, in main
File "compose\cli\main.py", line 116, in perform_command
File "compose\cli\main.py", line 712, in run
File "compose\cli\main.py", line 1020, in run_one_off_container
File "compose\cli\main.py", line 1100, in call_docker
File "distutils\spawn.py", line 220, in find_executable
File "ntpath.py", line 85, in join
UnicodeDecodeError: 'ascii' codec can't decode byte 0xcd in position 7: 
ordinal not in range(128)
Failed to execute script docker-compose

I try to search the same problems, but nothing helps.

Windows 10 Pro (English is not system language, if it’s important).

My Docker:

docker --version
Docker version 17.03.1-ce, build c6d412e
docker-compose --version
docker-compose version 1.11.2, build f963d76f

Dockerfile:

FROM python:2.7
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
ADD requirements.txt /code/
RUN pip install -r requirements.txt
ADD . /code/

requirements.txt:

Django
psycopg2

docker-compose.yml:

version: '2'
services:
db:
 image: postgres
web:
 build: .
 command: python manage.py runserver 0.0.0.0:8000
 volumes:
   - .:/code
 ports:
   - "8000:8000"
 depends_on:
   - db

The first place of django project - C:\Users\Наталья\DoDj , then I had tried from C:\DoDj (in order to escape kyrillic), but had the same error.

Thank your all!

You missed indentation line 3 of the docker-compose.yml file.
All services section needs to be indented :

Oh, sorry, I copied wrong. There are all indentation in my file:

version: '2'
services:
   db:
     image: postgres
   web:
     build: .
     command: python manage.py runserver 0.0.0.0:8000
     volumes:
       - .:/code
     ports:
       - "8000:8000"
     depends_on:
       - db

Hello,

I tried your files on a Linux and it works
$ docker --version
Docker version 1.12.6, build 78d1802
$ docker-compose --version
docker-compose version 1.11.2, build dfed245

~  Docker  django  docker-compose up --build
Building web
Step 1 : FROM python:2.7
 ---> 68caceba17ab
Step 2 : ENV PYTHONUNBUFFERED 1

[…]

Step 7 : ADD . /code/
 ---> 4ff8aa5810b0
Removing intermediate container b08f8aeeee91
Successfully built 4ff8aa5810b0
Creating django_db_1
Creating django_web_1
Attaching to django_db_1, django_web_1
db_1   | The files belonging to this database system will be owned by user "postgres".

[…]

db_1   | creating configuration files ... ok
web_1  | Performing system checks...
web_1  | 
web_1  | System check identified no issues (0 silenced).
web_1  | 
web_1  | You have 13 unapplied migration(s). Your project may not work properly until you apply the migrations for ap
web_1  | Run 'python manage.py migrate' to apply them.
web_1  | April 18, 2017 - 12:18:38
web_1  | Django version 1.11, using settings 'MyProject.settings'
web_1  | Starting development server at http://0.0.0.0:8000/
web_1  | Quit the server with CONTROL-C.

[…]

db_1   | LOG:  database system is ready to accept connections
db_1   | LOG:  autovacuum launcher started
web_1  | Quit the server with CONTROL-C.
web_1  | [18/Apr/2017 12:23:35] "GET / HTTP/1.1" 200 1716

At least you know that your files are good, may be it is the language may be not. I can not help more on Windows :-/

Is your system language English?

I think it’s because of my system language (kyrillic), but setting up the locale in Docerfile doesn’t help too.

I’m pretty sure that is a docker-compose bug. I have the same problem on my home machine, where my local username contains a Unicode character (in my case ‘ö’) just like yours.

Yes, I agree, it’s for sure in this

I’ve just noticed that with docker-compose version 1.12.0 (build ee0f34e1), this problem is fixed. You can get that version as part of Docker for Windows Edge channel distribution.

UPDATE

Scratch that. It worked exactly once from PowerShell, but no more… I have no idea why :angry: