Docker与Django组合:'ascii'编解码器无法解码位置7中的字节0xcd:序号不在范围内(128)

我刚从Docker和Django开始。 我尝试创build示例Django prodject,如下所示: https ://docs.docker.com/compose/django

我做了Dockerfile,requirements.txt和docker-compose.yml。 但是,当我尝试使用docker-compose命令创buildDjango项目时,出现错误:

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 

我试图search相同的问题,但没有任何帮助。

Windows 10 Pro(英文不是系统语言,如果重要的话)。

我的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 

泊坞窗,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 

谢谢你的一切!

更新:ntpath.py,部分行85,join:

 def join(path, *paths): path = os.fspath(path) if isinstance(path, bytes): sep = b'\\' seps = b'\\/' colon = b':' else: sep = '\\' seps = '\\/' colon = ':' try: if not paths: path[:0] + sep #23780: Ensure compatible data type even if p is null. result_drive, result_path = splitdrive(path) for p in map(os.fspath, paths): p_drive, p_path = splitdrive(p) if p_path and p_path[0] in seps: # Second path is absolute if p_drive or not result_drive: result_drive = p_drive result_path = p_path continue elif p_drive and p_drive != result_drive: if p_drive.lower() != result_drive.lower(): # Different drives => ignore the first path entirely result_drive = p_drive result_path = p_path continue # Same drive in different case result_drive = p_drive # Second path is relative to the first if result_path and result_path[-1] not in seps: result_path = result_path + sep result_path = result_path + p_path ## add separator between UNC and non-absolute path if (result_path and result_path[0] not in seps and result_drive and result_drive[-1:] != colon): return result_drive + sep + result_path return result_drive + result_path except (TypeError, AttributeError, BytesWarning): genericpath._check_arg_types('join', path, *paths) raise 

您应该在Dockerfile的顶部设置一个UTF-8 Dockerfile的区域设置

 export LANG=C.UTF-8