Are you doing it after installing Python, aren't you? Could you post your dockerfile to try to reproduce your problem? Did you try to execute an bash shell to test if that file was changed as expected?
This is my working Dockerfile example:
FROM ubuntu:14.04
MAINTAINER github/ojgarciab
# Use the "noninteractive" debconf frontend
ENV DEBIAN_FRONTEND noninteractive
# Add python
RUN apt-get update && apt-get install -y python && \
apt-get clean
RUN sed -i 's|encoding = "ascii"|encoding = "utf-8"|g' /usr/lib/python2.7/site.py
ADD ejemplo.py /ejemplo.py
CMD [ "python", "/ejemplo.py" ]
Before using sed
command the output was:
redstar@nvidiastar:~$ docker run -t python
ascii
And now the output is:
redstar@nvidiastar:~$ docker run -t python
utf-8
The content of ejemplo.py
script:
import sys
reload(sys)
print sys.getdefaultencoding();
Note that the path used was /usr/lib/python2.7/site.py
and not /usr/local/lib/python2.7/site.py
.