无法通过Docker和Vagrant安装MariaDB

时间:2015-01-20 10:45:36

标签: vagrant docker mariadb vagrantfile dockerfile

通过Dockerfile和Vagrant安装MariaDB时,我不断收到此错误:

New password for the MariaDB "root" user:
Use of uninitialized value $_[1] in join or string at /usr/share/perl5/Debconf/DbDriver/Stack.pm line 111.
invoke-rc.d: policy-rc.d denied execution of stop.
Use of uninitialized value $val in substitution (s///) at /usr/share/perl5/Debconf/Format/822.pm line 83, <GEN6> line 1.
Use of uninitialized value $val in concatenation (.) or string at /usr/share/perl5/Debconf/Format/822.pm line 84, <GEN6> line 1.
dpkg: error processing mariadb-server-10.0 (--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 mariadb-server:
 mariadb-server depends on mariadb-server-10.0 (= 10.0.15+maria-1~wheezy); however:
  Package mariadb-server-10.0 is not configured yet.

dpkg: error processing mariadb-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mariadb-server-10.0
 mariadb-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试过的每个MariaDB都会发生这种情况(10.0.15,10.1.2)。

我的DockerFile:

# vim:set ft=dockerfile:
FROM debian:wheezy

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql

# grab gosu for easy step-down from root
RUN gpg --keyserver pool.sks-keyservers.net --recv-keys B42F6819007F00F88E364FD4036A9C25BF357DD4
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/* \
    && curl -o /usr/local/bin/gosu -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture)" \
    && curl -o /usr/local/bin/gosu.asc -SL "https://github.com/tianon/gosu/releases/download/1.2/gosu-$(dpkg --print-architecture).asc" \
    && gpg --verify /usr/local/bin/gosu.asc \
    && rm /usr/local/bin/gosu.asc \
    && chmod +x /usr/local/bin/gosu \
    && apt-get purge -y --auto-remove curl

RUN apt-key adv --keyserver pool.sks-keyservers.net --recv-keys 199369E5404BD5FC7D2FE43BCBCB082A1BB943DB

ENV MARIADB_MAJOR 10.0
ENV MARIADB_VERSION 10.0.15+maria-1~wheezy

RUN echo "deb http://ftp.osuosl.org/pub/mariadb/repo/$MARIADB_MAJOR/debian wheezy main" > /etc/apt/sources.list.d/mariadb.list

RUN apt-get update \
    && apt-get install -y \
        mariadb-server=$MARIADB_VERSION \
    && rm -rf /var/lib/apt/lists/* \
    && rm -rf /var/lib/mysql \
    && mkdir /var/lib/mysql \
    && sed -ri 's/^(bind-address|skip-networking)/;\1/' /etc/mysql/my.cnf

VOLUME /var/lib/mysql

COPY docker-entrypoint.sh /

ENTRYPOINT ["/docker-entrypoint.sh"]

EXPOSE 3306
CMD ["mysqld"]

我在寻找可能的解决方案之后一直在Google上寻找,但我只能找到遇到相同问题的人,而不会发布任何解决方案。

我的流浪汉定义如下:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
    config.vm.define "mariadb" do |v|
        v.vm.provider "docker" do |d|
            d.build_dir = "./docker/mariadb"
            d.name = "mariadb"
            d.ports = ["3306:3306"]
            d.vagrant_vagrantfile = "#{DOCKER_HOST_VAGRANTFILE}"
            d.env = {
                MYSQL_ROOT_PASSWORD: "root",
                MYSQL_USER: "root",
                MYSQL_PASS: "root"
            }
        end
    end
end

此外,当我尝试安装MySQL而不是MariaDB时,它可以工作。所以我的想法是在设置MariaDB的根密码时出错。让我觉得这个错误就是在New password for the MariaDB "root" user:行之后弹出这个错误,然后它就说它还没有配置好。

可能问题出现在VagrantFile中了吗?但是我尝试改变env变量的设置方式并没有解决我的问题:(

如果有人可以帮助我,我会很高兴。

更新: 使用DockerFile:https://github.com/docker-library/mariadb/blob/d06c367c4b199f91b36f5f6fabf8305282b8abac/10.0/Dockerfile(我将权限更正为755)

1 个答案:

答案 0 :(得分:1)

解决方案是在我的虚拟机中添加更多RAM并完全重新创建它(因此打开virtualbox并删除boot2docker机器)。 (感谢用户2915097指出这一点!)