Docker的MYSQL安装错误

时间:2015-01-15 19:08:06

标签: mysql bash docker

我正在尝试从rhel6上的docker容器安装mysql。 这是我的dockerfile:

#HELLO
FROM rhel6
MAINTAINER xxxx

ADD ./perl /usr/bin/
RUN whereis perl
RUN ls -lrt /usr/bin/
RUN yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm -y
RUN yum update
RUN yum install mysql
ADD ./startup.sh /opt/startup.sh

EXPOSE 3306

CMD ["/bin/bash", "/opt/startup.sh"]

这是我的启动脚本:

if [ ! -f /var/lib/mysql/ibdata1 ]; then

    mysql_install_db

    /usr/bin/mysqld_safe &
    sleep 10s

    echo "GRANT ALL ON *.* TO admin@'%' IDENTIFIED BY 'changeme' WITH GRANT OPTION; FLUSH PRIVILEGES" | mysql

    killall mysqld
    sleep 10s
fi

/usr/bin/mysqld_safe

当我运行我的docker容器时,这是我得到的错误:

[xxxx ~/mysql]$ sudo docker run -i -t -p 3306:3306 mysql12 /bin/bash
bash-4.1# service mysqld start
mysqld: unrecognized service
bash-4.1# ls
bin  boot  dev  etc  home  lib  lib64  lost+found  media  mnt  mysql-community-release-el6-5.noarch.rpm  opt  proc  root  run  sbin  selinux  srv  sys  tmp  usr  var

这是我在运行docker run -i -t

时看到的输出
[xxxx/mysql]$ sudo docker run -i -t 3e7ed89e7d4a 
/opt/startup.sh: line 3: mysql_install_db: command not found
/opt/startup.sh: line 5: /usr/bin/mysqld_safe: No such file or directory
/opt/startup.sh: line 8: mysql: command not found
mysqld: no process killed
/opt/startup.sh: line 14: /usr/bin/mysqld_safe: No such file or directory

我没有多少安装软件的经验。我在步骤中遗漏了什么吗? 以前这已经成功了。 我相信我遵循的程序mysqld没有安装。 专家可以给我提示吗?

最近的错误:

---> Package mysql-community-client.x86_64 0:5.6.22-2.el6 will be installed
--> Processing Dependency: perl(Sys::Hostname) for package: mysql-community-client-5.6.22-2.el6.x86_64
--> Processing Dependency: perl(IPC::Open3) for package: mysql-community-client-5.6.22-2.el6.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: mysql-community-client-5.6.22-2.el6.x86_64
--> Processing Dependency: perl(File::Temp) for package: mysql-community-client-5.6.22-2.el6.x86_64
--> Processing Dependency: perl(Fcntl) for package: mysql-community-client-5.6.22-2.el6.x86_64
--> Processing Dependency: perl(Exporter) for package: mysql-community-client-5.6.22-2.el6.x86_64
--> Processing Dependency: /usr/bin/perl for package: mysql-community-client-5.6.22-2.el6.x86_64
---> Package mysql-community-common.x86_64 0:5.6.22-2.el6 will be installed
--> Processing Dependency: /usr/bin/perl for package: mysql-community-client-5.6.22-2.el6.x86_64
--> Finished Dependency Resolution
Error: Package: mysql-community-client-5.6.22-2.el6.x86_64 (mysql56-community)
           Requires: perl(Sys::Hostname)
Error: Package: mysql-community-client-5.6.22-2.el6.x86_64 (mysql56-community)
           Requires: /usr/bin/perl
Error: Package: mysql-community-client-5.6.22-2.el6.x86_64 (mysql56-community)
           Requires: perl(Getopt::Long)
Error: Package: mysql-community-client-5.6.22-2.el6.x86_64 (mysql56-community)
           Requires: perl(IPC::Open3)
Error: Package: mysql-community-client-5.6.22-2.el6.x86_64 (mysql56-community)
           Requires: perl(Exporter)
Error: Package: mysql-community-client-5.6.22-2.el6.x86_64 (mysql56-community)
           Requires: perl(File::Temp)
Error: Package: mysql-community-client-5.6.22-2.el6.x86_64 (mysql56-community)
           Requires: perl(Fcntl)
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest
2015/01/16 10:23:43 The command [/bin/sh -c yum install mysql] returned a non-zero code: 1

1 个答案:

答案 0 :(得分:1)

我假设您安装了mysql-community-release-el6-5.noarch.rpm,我看到http://dev.mysql.com/downloads/repo/yum/可以找到它。

这只是一个安装存储库的包而不是实际的mysql。你应该做的

yum install http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm -y
yum update
yum install mysql

安装该软件包或从http://dev.mysql.com/downloads/mysql/下载rpm: