Compose: Logs crash with `UnicodeEncodeError`

Created on 24 Dec 2015  Â·  17Comments  Â·  Source: docker/compose

By starting the following docker-compose.yml configuration with docker-compose up I get a UnicodeEncodeError. docker logs do not have this problem.

[plex@soda plex]$ cat docker-compose.yml
plex:
  image: linuxserver/plex
  environment:
    - VERSION=plexpass
    - PUID=1001
    - PGID=1002
  volumes:
    - /transcode
    - /mnt/data/plex/config:/config
    - /mnt/data/plex/homevideos:/data/homevideos
  net: "host"
  log_driver: journald
[plex@soda plex]$ docker-compose logs
Attaching to plex_plex_1
plex_1 | *** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...
plex_1 | *** Running /etc/my_init.d/10_add_user_abc.sh...
plex_1 | -----------------------------------
plex_1 |           _     _ _
plex_1 |          | |___| (_) ___
plex_1 |          | / __| | |/ _ \
plex_1 |          | \__ \ | | (_) |
plex_1 |          |_|___/ |_|\___/
plex_1 |                |_|
plex_1 | Brought to you by linuxserver.io
plex_1 | -----------------------------------
plex_1 | GID/UID
plex_1 | -----------------------------------
plex_1 | User uid:    1001
plex_1 | User gid:    1002
plex_1 | -----------------------------------
plex_1 | *** Running /etc/my_init.d/10_dbus.sh...
plex_1 | *** Running /etc/my_init.d/15_fix_for_transcode.sh...
plex_1 | *** Running /etc/my_init.d/20_apt_update.sh...
plex_1 | *** Running /etc/my_init.d/30_update_plex.sh...
plex_1 | Using version: 0.9.15.0.1621-344f193 from Plexpass latest
plex_1 | Upgrading from version: 0.9.12.19.1537-f38ac80 to version: 0.9.15.0.1621-344f193
plex_1 | --2015-12-24 22:21:54--  https://downloads.plex.tv/plex-media-server/0.9.15.0.1621-344f193/plexmediaserver_0.9.15.0.1621-344f193_amd64.deb
plex_1 | Resolving downloads.plex.tv (downloads.plex.tv)... 2400:cb00:2048:1::6814:709, 2400:cb00:2048:1::6814:609, 104.20.7.9, ...
plex_1 | Connecting to downloads.plex.tv (downloads.plex.tv)|2400:cb00:2048:1::6814:709|:443... connected.
plex_1 | HTTP request sent, awaiting response... 200 OK
plex_1 | Length: 128037122 (122M) [application/octet-stream]
Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 9, in <module>
    load_entry_point('docker-compose==1.5.2', 'console_scripts', 'docker-compose')()
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 54, in main
    command.sys_dispatch()
  File "/usr/lib/python3.5/site-packages/compose/cli/docopt_command.py", line 23, in sys_dispatch
    self.dispatch(sys.argv[1:], None)
  File "/usr/lib/python3.5/site-packages/compose/cli/docopt_command.py", line 26, in dispatch
    self.perform_command(*self.parse(argv, global_options))
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 171, in perform_command
    handler(project, command_options)
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 230, in logs
    LogPrinter(containers, monochrome=monochrome).run()
  File "/usr/lib/python3.5/site-packages/compose/cli/log_printer.py", line 28, in run
    self.output.write(line)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2018' in position 29: ordinal not in range(128)
arelogs kinbug

Most helpful comment

I am running into this issue as well. As a quick workaround you can export PYTHONIOENCODING before running Compose:

export PYTHONIOENCODING=utf8

The above workaround suggestion is taken from issue https://github.com/docker/compose/issues/3674. Also, there is a pending PR which is supposed to fix this issue: https://github.com/docker/compose/pull/4117.

All 17 comments

Looks like Unicode 2018 is a curly single quote; http://www.fileformat.info/info/unicode/char/2018/index.htm
Could there be a configuration file somewhere where you inadvertently used a curly quote instead of a regular one?

edit: nevermind, was reading in a hurry, I thought compose wasn't starting your project, but it starts, only the logging is causing an issue

I think so. Here is the section from docker logs plex_plex_1

Resolving downloads.plex.tv (downloads.plex.tv)... 2400:cb00:2048:1::6814:709, 2400:cb00:2048:1::6814:609, 104.20.7.9, ...
Connecting to downloads.plex.tv (downloads.plex.tv)|2400:cb00:2048:1::6814:709|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 128037122 (122M) [application/octet-stream]
Saving to: ‘/tmp/plexmediaserver_0.9.15.0.1621-344f193_amd64.deb’
     0K .......... .......... .......... .......... ..........  0% 1.49M 82s
    50K .......... .......... .......... .......... ..........  0% 2.43M 66s
   100K .......... .......... .......... .......... ..........  0% 16.5M 46s
   150K .......... .......... .......... .......... ..........  0% 3.76M 43s
   200K .......... .......... .......... .......... ..........  0% 15.5M 36s
   250K .......... .......... .......... .......... ..........  0% 9.88M 32s
Traceback (most recent call last):
  File "/usr/local/bin/docker-compose", line 9, in <module>
    load_entry_point('docker-compose==1.6.2', 'console_scripts', 'docker-compose')()
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/main.py", line 56, in main
    command.sys_dispatch()
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/docopt_command.py", line 23, in sys_dispatch
    self.dispatch(sys.argv[1:], None)
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/docopt_command.py", line 26, in dispatch
    self.perform_command(*self.parse(argv, global_options))
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/main.py", line 191, in perform_command
    handler(project, command_options)
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/main.py", line 663, in up
    log_printer.run()
  File "/usr/local/lib/python3.4/dist-packages/compose/cli/log_printer.py", line 29, in run
    self.output.write(line)
UnicodeEncodeError: 'ascii' codec can't encode character '\u2716' in position 22: ordinal not in range(128)

$ python3 --version && docker-compose --version
Python 3.4.2
docker-compose version 1.6.2, build 4d72027

@thaJeztah

I'm getting the same error with docker-compose 1.7.1. It's a Ghost blog image I've pushed to the HUB for ARM architecture. I think the PM2 splash screen may be causing the issue.

Linux piblog 4.4.8-2-ARCH #1 SMP Tue Apr 26 19:14:58 MDT 2016 armv7l GNU/Linux
Arch Linux ARM Raspberry PI 3
Docker version 1.11.1, build 5604cbe

$ docker-compose logs
Attaching to blog_blog_1
blog_1  | 
blog_1  |                         -------------
blog_1  | 
blog_1  |    Looking for a complete monitoring and management tool for PM2?
blog_1  |     _                             _        _            _
blog_1  |    | | _____ _   _ _ __ ___   ___| |_ _ __(_) ___ ___  (_) ___
blog_1  |    | |/ / _ \ | | | '_ ` _ \ / _ \ __| '__| |/ __/ __| | |/ _ \
blog_1  |    |   <  __/ |_| | | | | | |  __/ |_| |  | | (__\__ \_| | (_) |
blog_1  |    |_|\_\___|\__, |_| |_| |_|\___|\__|_|  |_|\___|___(_)_|\___/
blog_1  |              |___/
blog_1  | 
blog_1  |                           Features
blog_1  | 
blog_1  |                    - Real Time Dashboard
blog_1  |                    - CPU/Memory monitoring
blog_1  |                    - HTTP monitoring
blog_1  |                    - Event notification
blog_1  |                    - Custom value monitoring
blog_1  |                    - Real Time log display
blog_1  | 
blog_1  |                           Checkout
blog_1  | 
blog_1  |                    https://keymetrics.io/
blog_1  | 
blog_1  |                         -------------
blog_1  | 
blog_1  | pm2 launched in no-daemon mode (you can add DEBUG="*" env variable to get more messages)
blog_1  | 2016-05-28 07:32:53: [PM2][WORKER] Started with refreshing interval: 30000
blog_1  | 2016-05-28 07:32:53: [[[[ PM2/God daemon launched ]]]]
blog_1  | 2016-05-28 07:32:53: BUS system [READY] on port /home/ghost/.pm2/pub.sock
blog_1  | 2016-05-28 07:32:53: RPC interface [READY] on port /home/ghost/.pm2/rpc.sock
blog_1  | 2016-05-28 07:32:53: [PM2] Starting index.js in fork_mode (1 instance)
blog_1  | 2016-05-28 07:32:53: Starting execution sequence in -fork mode- for app name:blog id:0
blog_1  | 2016-05-28 07:32:53: App name:blog id:0 online
blog_1  | 2016-05-28 07:32:54: [PM2] Done.
Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 9, in <module>
    load_entry_point('docker-compose==1.7.1', 'console_scripts', 'docker-compose')()
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 58, in main
    command()
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 109, in perform_command
    handler(command, command_options)
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 420, in logs
    event_stream=self.project.events(service_names=options['SERVICE'])).run()
  File "/usr/lib/python3.5/site-packages/compose/cli/log_printer.py", line 97, in run
    self.output.write(line)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 40-122: ordinal not in range(128)

+1

I'm also getting this error with docker-compose version 1.7.1, build 6c29830. I'm trying to run a Gulp task inside the container and one of the tasks prints an arrow → (Unicode character 2192), which crashes the log of docker-compose. Luckily I can still see the logs when going through the docker client but it would be nice to see the logs via docker-compose.

@aanand hey Anand, this is the error I was talking to you about after day 2 of Dockercon.

UnicodeEncodeError: 'ascii' codec can't encode characters in position 40-122: ordinal not in range(128)

@alexellis Can you provide a failing case? Ideally, a docker-compose.yml with a single service and just enough configuration to reproduce the error.

I believe #4016 should fix this issue - can you try out 1.9.0-rc1 and confirm? https://github.com/docker/compose/releases/tag/1.9.0-rc1

Traceback (most recent call last):
  File "/usr/bin/docker-compose", line 9, in <module>
    load_entry_point('docker-compose==1.8.0', 'console_scripts', 'docker-compose')()
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 61, in main
    command()
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 113, in perform_command
    handler(command, command_options)
  File "/usr/lib/python3.5/site-packages/compose/cli/main.py", line 848, in up
    log_printer.run()
  File "/usr/lib/python3.5/site-packages/compose/cli/log_printer.py", line 97, in run
    self.output.write(line)
UnicodeEncodeError: 'ascii' codec can't encode character '\xb5' in position 132: ordinal not in range(128)

```[sergiofbsilva@smeg rest-microservices]$ docker version
Client:
Version: 1.12.1
API version: 1.24
Go version: go1.7
Git commit: 23cf638
Built: Fri Aug 19 02:03:02 2016
OS/Arch: linux/amd64

Server:
Version: 1.12.1
API version: 1.24
Go version: go1.7
Git commit: 23cf638
Built: Fri Aug 19 02:03:02 2016
OS/Arch: linux/amd64
```

still get this issue. Any ideas?

@GriwMF / @sergiofbsilva can you provide a minimal Github repo with just enough to reproduce the issue?

@alexellis sorry, it happened once but I can't recall where, if I do I will post here.

@shader That project works fine for me on Ubuntu 16.04 and Compose 1.11.1. What OS/distro are you on? Output of docker-compose version? echo $LANG?

Also state Python version. The issues appear to be with Python 3 as the default runtime.

I am running into this issue as well. As a quick workaround you can export PYTHONIOENCODING before running Compose:

export PYTHONIOENCODING=utf8

The above workaround suggestion is taken from issue https://github.com/docker/compose/issues/3674. Also, there is a pending PR which is supposed to fix this issue: https://github.com/docker/compose/pull/4117.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leiblix picture leiblix  Â·  3Comments

DhairyashilBhosale picture DhairyashilBhosale  Â·  3Comments

dazorni picture dazorni  Â·  3Comments

bitver picture bitver  Â·  3Comments

dimsav picture dimsav  Â·  3Comments