DockerのUbuntuイメージでMySQLを動かしたい
普通にapt-get install
するとUpstartに繋がらなくて失敗する。
ore@localhost ~ $ docker run -i -t ubuntu:12.10 /bin/bash root@aaee59dede24:/# root@aaee59dede24:/# apt-get install -y mysql-server ... ... Setting up mysql-server-5.5 (5.5.27-0ubuntu2) ... initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused initctl: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused start: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused invoke-rc.d: initscript mysql, action "start" failed. dpkg: error processing mysql-server-5.5 (--configure): subprocess installed post-installation script returned error exit status 1 Setting up libhtml-template-perl (2.91-1) ... dpkg: dependency problems prevent configuration of mysql-server: mysql-server depends on mysql-server-5.5; however: Package mysql-server-5.5 is not configured yet. dpkg: error processing mysql-server (--configure): dependency problems - leaving unconfigured Processing triggers for libc-bin ... ldconfig deferred processing now taking place Processing triggers for ureadahead ... Errors were encountered while processing: mysql-server-5.5 mysql-server E: Sub-process /usr/bin/dpkg returned an error code (1)
ググったらissueが上がっていた。
https://github.com/dotcloud/docker/issues/1024
Dockerが/sbin/initを独自のものに置き換えていてUpstartが起動しないのが原因らしい。書いてあるworkaround通りにやったら上手くいった。
root@aaee59dede24:/# dpkg-divert --local --rename --add /sbin/initctl Adding 'local diversion of /sbin/initctl to /sbin/initctl.distrib' root@aaee59dede24:/# ls -l /sbin/initctl ls: cannot access /sbin/initctl: No such file or directory root@aaee59dede24:/# ls -l /sbin/initctl.distrib -rwxr-xr-x 1 root root 155560 Oct 12 2012 /sbin/initctl.distrib root@aaee59dede24:/# ln -s /bin/true /sbin/initctl root@aaee59dede24:/# apt-get install -y mysql-server Reading package lists... Done Building dependency tree... Done mysql-server is already the newest version. 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. 2 not fully installed or removed. After this operation, 0 B of additional disk space will be used. Setting up mysql-server-5.5 (5.5.27-0ubuntu2) ... Setting up mysql-server (5.5.27-0ubuntu2) ... root@aaee59dede24:/#