相关Github问题:https://github.com/docker-library/mysql/issues/441
尝试安装Sequel gem(https://github.com/jeremyevans/sequel)失败,并且“无法构建gem native扩展”。 Docker镜像:
FROM mysql:latest
RUN apt-get update
RUN apt-get install -y rubygems ruby-mysql2 wget build-essential libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
RUN gem install mysql2
输出:
$ docker build -t "mysqltest" .
Sending build context to Docker daemon 8.704kB
Step 1/4 : FROM mysql
---> a8a59477268d
Step 2/4 : RUN apt-get update
---> Using cache
---> ab35c534ffcf
Step 3/4 : RUN apt-get install -y rubygems ruby-mysql2 wget build-essential libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
---> Using cache
---> b703bf4ef78d
Step 4/4 : RUN gem install mysql2
---> Running in 79790b7f4506
Building native extensions. This could take a while...
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.3.0/gems/mysql2-0.5.1/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20180610-8-1ixqzle.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes
checking for MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.h... no
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/lib/x86_64-linux-gnu
-----
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.5.1/mkmf.log
current directory: /var/lib/gems/2.3.0/gems/mysql2-0.5.1/ext/mysql2
make "DESTDIR=" clean
current directory: /var/lib/gems/2.3.0/gems/mysql2-0.5.1/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
Makefile:255: recipe for target 'mysql2.so' failed
make: *** [mysql2.so] Error 1
make failed, exit code 2
Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.5.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.5.1/gem_make.out
The command '/bin/sh -c gem install mysql2' returned a non-zero code: 1
mkmf.log内容:https://gist.github.com/ifischer/529950ce6af29280d5c778e702321b35
答案 0 :(得分:0)
发现问题: 我需要安装default-libmysqlclient-dev而不是libmysqlclient-dev:
FROM mysql:latest
RUN apt-get update
RUN apt-get install -y rubygems ruby-mysql2 wget build-essential default-libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
RUN gem install mysql2 sequel sqlite3