Mysql: Is there a plan to make an alpine build of mysql?

Created on 18 Jun 2016  路  34Comments  路  Source: docker-library/mysql

Request

Most helpful comment

From the referenced _MySQL ticket:_

[27 Apr 16:05] Paul Dubois
Posted by developer:
Noted in 8.0.2 changelog.
MySQL now compiles on Alpine Linux.

I guess there's green light for an _Alpine version_.

All 34 comments

I think this comment is our current response. ie, we want to be sure that upstream supports running it on Alpine Linux.

I am especially hesitant with regards to the non-glibc: musl-libc, since it has caused issues in the past.

Yeah, currently MySQL doesn't build on Alpine, unfortunately.

+1

Now that postgres (from your comment above) and many other containers (node, etc) have official alpine variants, is it time to revisit this?

I think improvements in the alpine c library now allows MySQL to build. Official support from Oracle isn't there, but we may be able to take another look at it.

Is PR welcomed for alpine build, I was using recently alpine built mysql on our staging servers and it runs so far without problems.

So I've found that we are using mariadb on staging and mysql doesn't compile currently with musl, see corresponding bug

So I've found that we are using mariadb on staging and mysql doesn't compile currently with musl, see corresponding bug

The last comment in MySQL ticket #80322 says that compilation on alpine is fixed for MySQL 8.0.2.

I wonder if they'd be open to a backport to 5.6/5.7?

Or if not, then perhaps a good first step would be adding an alpine config for just the MySQL 8.x image?

Yeah, I've noticed that ticket, will try to compile mysql under alpine in coming week, if it succeeds, I'll be happy to give PR with alpine image as soon as stable MySQL 8.x is released. Don't know if there are any plans to backport those fixes (changes) to 5.6 and 5.7.

Note that the ticket lists it as fixed in 8.0.2, which is not yet released.

I'm working on a template system for the images (so we can offer OracleLinux-based ones without breaking every image out there that extends the Debian-based images). Once that's in I think adding alpine images is a good idea.

It would be the top if #255 is also solved in this new alpine based image.

One other issue is that even if the build is fixed, unless MySQL gets official Alpine support we won't build and publish packages for it.

From the referenced _MySQL ticket:_

[27 Apr 16:05] Paul Dubois
Posted by developer:
Noted in 8.0.2 changelog.
MySQL now compiles on Alpine Linux.

I guess there's green light for an _Alpine version_.

Is there any PR going on for this issue?

@AyushyaChitransh From looking at https://github.com/docker-library/mysql/pulls I don't see any pending one.

So I guess there are currently plans to develop it and it is yet to be started.

I use leafney/docker-alpine-mysql image, it installs mysql from alpine packages

I guess we still need to wait for the MySQL 8 release, as it is the first release to officially support alpine linux.

Yeah, this isn't just blocked on the ability to build, but also Oracle
officially supporting it. Just being able to build it is not sufficient.

Okay, it's been a while! Any progress on this one?

I think https://github.com/docker-library/mysql/issues/179#issuecomment-310972070 is still accurate (but perhaps @ltangvald can comment further as to whether Oracle has decided to officially support MySQL on Alpine):

... unless MySQL gets official Alpine support we won't build and publish packages for it.

@karser

I use leafney/docker-alpine-mysql image, it installs mysql from alpine packages

apk add mysql mysql-client

Sorry, but that installs MariaDB, not MySQL.

MySQL 8.0 does now build with alpine, and we've done some work on creating Docker images, but there are a couple of issues:

  • MySQL dependencies add much more to the size than those of PG, so you end up with an image of ~150MB instead of ~40MB
  • Oracle doesn't publish MySQL for Alpine, so image build would also need to build the server (but this is also true for PG, I think?)

@ltangvald I'd be very curious how you managed to get down to ~150MB -- I've done some work on this and only got as low as ~196MB, and that's manually pruning a number of things, especially extra binaries (loosely based on what the -core packages include)

PostgreSQL does indeed build from source on Alpine, so that's not a big deal -- on my 12-core system I'm able to build the Alpine image I've been working on in ~9 minutes, and we've got a really beefy arm64v8 system I've been testing on as well that builds in a similar time frame, which is perfectly reasonable IMO (it'll be slower on our AWS amd64 workers, but such is life).

Honestly, I think even ~196MB for an Alpine image is still pretty interesting compared to ~343MB for the Debian alternative.

We built alpine packages very similar to the minimisation used for the mysql-community-server-minimal rpm (that in turn is used for the mysql/mysql-server image). The differences there are that the oraclelinux:7-slim one is 246MB, and the alpine one around 150MB (talking 8.0 now). The savings in size come mostly from the removal of binaries. Also, the run script currently depends on bash and mysql still has a runtime dependency on gcc (this would be the differences to a "pure" alpine binary). Note that the pg binary itself is 8MB whereas mysql is 40MB, PG is written in C if I'm not mistaken.

Like @ltangvald mentioned the alpine thing comes at the cost of having to have Oracle support for it in place, currently difficult to prioritise on our end (although we do have a working prototype, the infamous ~150MB alpine image).

Maybe it's enough in terms of size if we try to get the official and supported Oracle one based on Oracle linux in? This would make use have a 246MB image for free (and it is supported and we probably can maintain that in the future, especially if it is identical or easily generated from the mysql/mysql-server one).

We'll discuss that a bit more internally and hopefully we'll be able to make more concrete suggestions soon. Our main interests here are to keep the duplication of code (run scripts mainly, but also the Dockerfiles) to a minimum in order to be able to maintain and support and help.

@tianon if you have a pr or branch with your alpine sources I can comment on what is the difference with my prototype. Maybe if you take a look at https://github.com/mysql/mysql-server/blob/8.0/packaging/rpm-docker/mysql.spec.in that can also help.

Is there any update on that?

For the upstream image I've experimented a little with stripping away any non-essential parts of the image, but doing a multi-stage build that only copies over what the MySQL binaries/entrypoint link to. This gives an OracleLinux-based image of about 100MB, vs the alpine image's 150MB (though you lose most OS functionality from it).
Would this be a relevant alternative, or are there other reasons besides size to make it alpine-based?

As far as I know, Alpine images were introduced because they were significantly smaller, if that is not the case then I don't see a reason to have them. muslc and its strict POSIX compliance has been the source of more than a few issues across the official images. Here is a quick sampling of some of them:

https://github.com/docker-library/python/issues/211
https://github.com/docker-library/postgres/issues/276
https://github.com/docker-library/postgres/issues/327
https://github.com/docker-library/docs/issues/904
https://github.com/docker-library/ruby/issues/196
https://github.com/docker-library/php/issues/612

FYI, multi-stage builds are not supported by offical-images: https://github.com/docker-library/official-images/issues/3383

I use this build a lamp with alpine linux, Lamp Alpine Linux, to build lamp and Drupal environment, but it failed to auto install Drupal with mysql, this means: The Dockerfile in Drupal directory, there is a RUN command at last row of the file, it can't auto start mysqld to install Drupal code, Any idea of this?

how do I do to fix this?

are there any news about this? any hope to see mysql 5 with alpine in future, or only planning to do it for version 8 ?

I'd like >=5.7.0 too, I'm getting frustrated with hitting ^C in my dockerized mysql client and losing the session

It's also possible to build glibc into alpine as a first step (as it's done here https://github.com/sgerrand/alpine-pkg-glibc) and then build MySQL based on glibc

At this point getting even version just for MySQL 8 would be a blessing...

some update?

Was this page helpful?
0 / 5 - 0 ratings