Experiencing incorrect encoding on UTF8 text output from a tomcat:8.0 container retrieved from a mysql:5.6 container.
Connecting to the MySQL container directly and querying on the shell proves the text is stored in the database correctly.
Also UTF8 content within templates is output from the tomcat container fine.
The JDBC connector string reads: nfc.jdbc.mysql.url=jdbc:mysql://mysql:3306/mydatabase?autoReconnect=yes&useUnicode=yes&characterEncoding=UTF-8
Here's the tomcat Dockerfile I'm using:
FROM tomcat:8.0
RUN apt-get update && \
apt-get -y install libmysql-java
RUN echo 'CLASSPATH=/usr/share/java/mysql.jar' >> /usr/local/tomcat/bin/setenv.sh
And the MySQL Dockerfile:
FROM mysql:5.6
RUN { \
echo '[mysqld]'; \
echo 'character-set-server = utf8'; \
echo 'collation-server = utf8_unicode_ci'; \
echo '[client]'; \
echo 'default-character-set=utf8'; \
echo '[mysql]'; \
echo 'default-character-set=utf8'; \
} > /etc/mysql/conf.d/charset.cnf
VOLUME /var/lib/mysql
The Tomcat run command is:
docker run \
--rm \
--name tomcat-server \
--volume $(pwd)/../../webapp:/usr/local/tomcat/webapps/mywebapp \
--volume $(pwd)/../../tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml:ro \
--link mysql-server:mysql \
--publish 8088:8080 \
--tty \
--interactive \
tomcat-server
I'm using the same MySQL image to provide content to other docker container web servers (python/django) which is being pulled and output with the correct encoding.
I have no real understanding of the contents of the tomcat webapp and don't really know Java.
The developer has demonstrated the application running from a Windows server producing the correctly encoded data, however they have no understanding of Docker, and so we're currently spinning our wheels not getting anywhere!