MySQL client in official Ruby docker image

I’ve got a Sinatra app, it uses MySQL, and it works on my laptop! It didn’t work in a docker container though and instead was hemorrhaging this terribly unhelpful message when using prepared statements:

Using unsupported buffer type: 245 (parameter: 7)

Wow was that ever useless. It took a while but I got to the bottom of it. The official Ruby docker image is built on Debian Jesse and ships with MySQL 5.5, but I’m using MySQL 5.7 (yay for JSON support!). The mysql2 gem is a native extension which links against libmysql. Turns out MySQL 5.5 client doesn’t play nice with MySQL 5.7 server.

 

The fix was to pull in the mysql distribution source list and install the latest libmysqlclient-dev. I put the list in a gist if you want it (Oracle makes it super cumbersome packaging the list as a deb, honestly Oracle…). Afterwards add this do your Docker file:

ADD mysql.list /etc/apt/sources.list.d/mysql.list
RUN apt-get update
RUN apt-get install -y --force-yes mysql-common libmysqlclient-dev
RUN gem install mysql2

And hooray it works! If Googling this baffling error message brought you here, don’t forget to like, comment and subscribe.

 

Advertisements

About robertlabrie
DevOps Engineer at The Network Inc in metro Atlanta. Too many interests to list here, check out my posts, or look me up on LinkedIn

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: