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

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

问题描述:

我在我的docker bash中遇到问题,我试图在django上使用docker-compose exec web python manage.py createsuperuser创建一个超级用户,但我在下面有这个错误。如何在docker上从ascii postgresql数据库切换到utf8?

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的在代替UTF-8“ASCII”编码,什么是编码我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 

你在你的搬运工,compose.yml有波浪符( “​​E”)


编辑。可能你在所涉及的路径中有口音,并且可能你正在面对主机中的一些python错误。您可以尝试更新主机中的python(docker-compose是由python制作的)。

+0

我不这样做,我已经检查过,我已经发布了我的文件 – jjyoh

+1

可能您在所涉及的路径中有重音符号?码头工人组成的地方。 – Robert

+0

是的,我找到了带口音的路径...谢谢 – jjyoh