6

So my ultimate end goal is to run a MySQL Docker container (say tutum/mysql from the public registry) and then link a Gitlab Docker container (say sameersbn/gitlab) to it where both containers use persistent storage.

However, I am stuck on the MySQL part. Every time I try and run a pre-made MySQL Docker container (mysql, tutum/mysql and sameersbn/mysql) as outlined below, I get the below output.

Steps

This is just one way of getting to the error message below.

  1. docker.io pull tutum/mysql:latest
  2. docker.io run -it tutum/mysql bash
  3. Once attached to the new container run "/run.sh" (as per tutum/mysql dockerfile)
  4. At this point a "Waiting for confirmation of MySQL service startup" message constantly repeats.
  5. At this point if I cancel the "/run.sh" command and start MySQL myself I get the error message below.

Output:

root@1bbeb34f3491:/# mysqld

140730 4:49:04 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.

140730 4:49:04 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.

140730 4:49:04 [Note] Plugin 'FEDERATED' is disabled.

mysqld: Table 'mysql.plugin' doesn't exist

140730 4:49:04 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.

140730 4:49:04 InnoDB: The InnoDB memory heap is disabled

140730 4:49:04 InnoDB: Mutexes and rw_locks use GCC atomic builtins

140730 4:49:04 InnoDB: Compressed tables use zlib 1.2.8

140730 4:49:04 InnoDB: Using Linux native AIO

140730 4:49:04 InnoDB: Initializing buffer pool, size = 128.0M

140730 4:49:04 InnoDB: Completed initialization of buffer pool

140730 4:49:04 InnoDB: highest supported file format is Barracuda.

140730 4:49:04 InnoDB: Waiting for the background threads to start

140730 4:49:05 InnoDB: 5.5.37 started; log sequence number 1595675

140730 4:49:05 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306

140730 4:49:05 [Note] - '0.0.0.0' resolves to '0.0.0.0';

140730 4:49:05 [Note] Server socket created on IP: '0.0.0.0'.

140730 4:49:05 [ERROR] Can't start server : Bind on unix socket: Permission denied

140730 4:49:05 [ERROR] Do you already have another mysqld server running on socket: /var/run/mysqld/mysqld.sock ?

140730 4:49:05 [ERROR] Aborting

140730 4:49:05 InnoDB: Starting shutdown... 140730 4:49:06 InnoDB: Shutdown completed; log sequence number 1595675 140730 4:49:06 [Note] mysqld: Shutdown complete

Addressing the errors

  • "Please run mysql_upgrade to create it" => run mysql_upgrade command which outputs

root@1bbeb34f3491:/# mysql_upgrade

Looking for 'mysql' as: mysql

Looking for 'mysqlcheck' as: mysqlcheck

FATAL ERROR: Upgrade failed

  • "Do you already have another mysqld server running on socket" => Nope. Running service mysql stop does nothing and running ps doesn't show mysqld. Running ls -a /var/run/mysqld/ suggests that the socket file doesn't exist.

No matter which MySQL container I try, eventually when I start MySQL the same error message came up. This almost certainly means there is something wrong with my setup which confuses me because I thought a Docker container, with no exposed ports or persistent storage, would be isolated from the system Docker is installed on?

I have also tried running a MySQL container with the -d flag then running a fresh ubuntu 14.04 container (docker.io run -it --link mysql:mysql ubuntu:14.04 bash) linked to it. On the Ubuntu container I installed mysql-client through apt-get and tried to connect to the MySQL container on the ip address in MYSQL_PORT_3306_TCP_ADDR but that doesn't work either.

Equally the problem might be that I do not understand how Docker works. If this is the case, can someone create a set of steps that uses one of the MySQL containers on the Docker index and then link a container to it that can connect. This will also help to see whether there is something wrong with my Docker installation (or some other unknown problem that is causing this issue).

My host system is running Ubuntu 14.04 and Docker was installed through apt-get and is version 0.9.1.

I wasn't quite sure what to put in this explanation because the problem seems quite weird to me. If there is anything I have missed please ask and I will add it for you.

Thanks, JamesStewy

Community
  • 1
  • 1
JamesStewy
  • 1,058
  • 15
  • 26
  • I think this question may be better suited for [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) – Barranka Jul 31 '14 at 22:31
  • Sure: https://unix.stackexchange.com/questions/147786/running-mysql-in-a-docker-container. – JamesStewy Jul 31 '14 at 23:51
  • Wondering: what is your host? Are you using a local actual machine or some cloud VPS? And you say you use docker 0.9.1, you should try a more recent one (about 1.1.1 I guess) to double-check this is not related to a bug. – Baptiste Mathus Aug 01 '14 at 13:09
  • It is a physical local machine with Ubuntu 14.04 installed straight on it. I realized that my Docker version was far behind yesterday but for some reason the Docker package on apt-get is only at version 0.9.1. So I followed these instructions (http://askubuntu.com/a/473720/89270) and am now running 1.1.2. This hasn't changed anything unfortunately. – JamesStewy Aug 01 '14 at 22:01
  • @JamesStewy, were you able to figure this one out? I'm facing the same issue. – haaduken Jun 05 '15 at 07:18
  • Unfortunately no. In the end I ended up working around the issue by using these two mysql images from the docker registry: [sameersbn/mysql](https://registry.hub.docker.com/u/sameersbn/mysql/) and [orchardup/mysql](https://registry.hub.docker.com/u/orchardup/mysql/). – JamesStewy Jun 05 '15 at 12:55

1 Answers1

4

This works for me: docker run -d -p 3306:3306 -e MYSQL_PASS="mypass" tutum/mysql

No need to run the script from bash, no need for anything clever.

qwertyboy
  • 1,576
  • 15
  • 25