0

I am trying to install mysql from a docker container on rhel6. This is my 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"]

This is my startup script:

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

When i run my docker container, this is the error i am getting:

[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

This is the output i see when i run 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

I dont have much experience installing software. Am i missing anything in my steps? This has previously worked on centos. I believe with the procedure i followed mysqld is not getting installed. Can experts suggest me tips?

MOST RECENT ERROR:

---> 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
2
  • Why don't you run the container with /bin/bash so you can explore and see if mysqld is in fact installed? Once your image is built, just run docker run -t -i my_repo/my_image /bin/bash. You can now explore inside the container with Bash and see what's missing. Commented Jan 15, 2015 at 19:14
  • yes i ran the run command. look at my edited question. Commented Jan 15, 2015 at 19:23

1 Answer 1

1

I am assuming you installed mysql-community-release-el6-5.noarch.rpm which I see is available at http://dev.mysql.com/downloads/repo/yum/.

This is just a package to install the repositories as opposed to actual mysql. you should do

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

after installing that package or download the rpm from http://dev.mysql.com/downloads/mysql/:

Sign up to request clarification or add additional context in comments.

8 Comments

I tried to use yum install directly. Yet i see errors. I edited my post with the lastest Dockerfile and errors.
I still don't see an install of mysql in your docker file.
i made the changes. i am getting an error saying that it cannot find perl though i added the perl from local file system/
Why not yum install perl?
Also why aren't you using the offical mysql container? registry.hub.docker.com/_/mysql
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.