运行docker-compose build时出现UnicodeEncodeError

时间:2017-11-19 16:26:45

标签: python docker docker-compose

在运行docker-compose构建时,我在构建期间遇到Python UnicodeEncodeError和docker-compose崩溃。我已经在网上进行了大量的搜索,并发现建议将语言环境设置为C.UTF8的帖子,但这似乎并没有为我解决问题。

这里有完整的错误:

Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 11, in <module>
    load_entry_point('docker-compose==1.17.0', 'console_scripts', 'docker-compose')()
  File "/usr/lib/python3.6/site-packages/compose/cli/main.py", line 68, in main
    command()
  File "/usr/lib/python3.6/site-packages/compose/cli/main.py", line 121, in perform_command
    handler(command, command_options)
  File "/usr/lib/python3.6/site-packages/compose/cli/main.py", line 249, in build
    build_args=build_args)
  File "/usr/lib/python3.6/site-packages/compose/project.py", line 343, in build
    service.build(no_cache, pull, force_rm, build_args)
  File "/usr/lib/python3.6/site-packages/compose/service.py", line 927, in build
    all_events = stream_output(build_output, sys.stdout)
  File "/usr/lib/python3.6/site-packages/compose/progress_stream.py", line 23, in stream_output
    print_output_event(event, stream, is_terminal)
  File "/usr/lib/python3.6/site-packages/compose/progress_stream.py", line 90, in print_output_event
    stream.write("%s%s" % (event['stream'], terminator))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 58-60: ordinal not in range(128)

这是我的Dockerfile:

FROM node:boron

WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install

RUN apt-get clean && apt-get update && apt-get install -y locales
RUN locale-gen C.UTF-8
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8
ENV PYTHONIOENCODING UTF-8

COPY . .

RUN npm install --global bower

WORKDIR /usr/src/app/public
RUN bower install --allow-root

WORKDIR /usr/src/app

EXPOSE 8080

ENTRYPOINT ["npm"]
CMD ["start"]

我的docker-compose版本是1.17.0。

1 个答案:

答案 0 :(得分:0)

我的问题是我使用的是Arch Linux AUR上提供的过时版本的docker-compose。我从docker的网站上下载了tarball,它解决了这个问题。