【问题标题】:How to switch from ascii postgresql database to utf8 on docker?如何在 docker 上从 ascii postgresql 数据库切换到 utf8?
【发布时间】:2017-06-29 13:52:20
【问题描述】:

我的 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 是用 'ascii' 而不是 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

Docker-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

【问题讨论】:

    标签: django postgresql docker utf-8


    【解决方案1】:

    您的 docker-compose.yml 中有一个波浪号(“é”)


    编辑。可能您在所涉及的路径中有重音,并且您可能在主机中遇到了一些 python 错误。您可以尝试在主机中更新python(docker-compose是用python制作的)。

    【讨论】:

    • 可能您在相关路径中有重音符号?放置 docker compose 的位置。
    • 是的,我找到了一条带重音的路径...谢谢
    猜你喜欢
    • 2012-02-07
    • 1970-01-01
    • 2011-05-20
    • 2018-05-01
    • 2016-10-30
    • 1970-01-01
    • 1970-01-01
    • 2015-06-04
    • 2019-10-31
    相关资源
    最近更新 更多