Closed
Description
I'm trying to run a simple Python app in Docker, using the official python:2.7
image.
My problem is that unless I enable -t
/ --tty
in docker run
, the python print
command terminates when trying to print Unicode characters:
UnicodeEncodeError: 'ascii' codec can't encode characters...
If I enable --tty
it works without errors.
The problem is that I want to run this process in the background, using --detach
and that mode does not support --tty
.
What kind of changes do I need to make to my Dockerfile so that it doesn't terminate when trying to print Unicode strings?
Minimal Dockerfile:
FROM python:2.7
CMD [ "python", "-c", "print (u'\\xc1')" ]
Minimal broken run command:
# error
docker run myimage
# working
docker run --tty myimage
Note: it also works without problems in the official python:3.5
image.