如何在docker上从ascii postgresql数据库切换到utf8?

时间:2017-06-29 13:52:20

标签: django postgresql docker utf-8

我在我的docker bash中遇到问题,我试图使用docker-compose exec web python manage.py createsuperuser在django上创建一个超级用户但我在下面有这个错误。

Traceback (most recent call last):
  File "docker-compose", line 3, in <module>
  File "compose\cli\main.py", line 68, in main
  File "compose\cli\main.py", line 118, in perform_command
  File "compose\cli\main.py", line 431, in exec_command
  File "compose\cli\main.py", line 1236, 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 0xe9 in position 8: ordinal not in range(128)
Failed to execute script docker-compose

我认为这是因为我的数据库Postgresql编码在&#39; ascii&#39;而不是utf-8,将我的psql数据库编码为utf-8的命令是什么?

Dockerfile

FROM python:3.5
ENV PYTHONUNBUFFERED 1
RUN mkdir /config
ADD /config/requirements.pip /config/
RUN pip install -r /config/requirements.pip
RUN mkdir /src;
WORKDIR /src

多克尔-compose.yml

version: '2'
services:
  nginx:
    image: nginx:latest
    container_name: NGINX
    ports:
      - "8000:8000"
    volumes:
      - ./src:/src
      - ./config/nginx:/etc/nginx/conf.d
      - /static:/static
      - /media:/media
    depends_on:
      - web
  web:
    restart: always
    build: .
    container_name: DJANGO
    command: bash -c "python manage.py collectstatic --noinput && python manage.py makemigrations && python manage.py migrate && gunicorn oqtor.wsgi -b 0.0.0.0:8000"
    depends_on:
      - db
    volumes:
      - ./src:/src
      - /static:/static
      - /media:/media
    expose:
      - "8000"

  db:
    image: postgres:latest
    container_name: PSQL

1 个答案:

答案 0 :(得分:1)

你的docker-compose.yml

中有一个波形符(“é”)

编辑。可能你在相关路径中有重音,可能你在主机上面临一些python错误。您可以尝试在主机中更新python(docker-compose是在python中创建的。)