Docker Community Forums

Share and learn in the Docker community.

Unable to Run mysql command in docker file

docker

(Roiebeck) #1

Hello,
I have the following dockerFile(created by me)
the mysql-settings.sh file only edits the my.cnf file
the problem is when I am trying to run the mysql command
mysql -uroot -e "GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘root’ WITH GRANT OPTION;"
the error states: db PRIVILEGES does not exist,
of course when I enter the container(bash …) I can run everything OK, there is no password needed for mysql when connecting locally, the version that is installed is mysql 5.1(centos 6…)

can you please help me understand the problem?
Regards,

p.s the host is atomicOS using Virtual box on windows…

The Docker file:
#Dockerfile
FROM centos:6

#copy configuration of my.cnf
COPY ./docker/install/* /root/install/
RUN chmod +x /root/install/mysql-settings.sh

#mysql
RUN yum -y update; yum clean all
RUN yum install -y vim
RUN yum install -y mysql mysql-server
RUN mysql_install_db
RUN chkconfig mysqld on

##editing the my.cnf file

RUN /etc/init.d/mysqld stop &&
/root/install/mysql-settings.sh &&
/etc/init.d/mysqld start

##Allow remote connections from other containers

#RUN /etc/init.d/mysqld start &&
#mysql -uroot -e “GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘mypass’ WITH GRANT OPTION;” &&
#mysql -uroot -e “SET PASSWORD FOR root@’%’ = PASSWORD(‘mypass’);” &&
#mysql -uroot -e FLUSH PRIVILEGES;

EXPOSE 3306

#start services
CMD ["/sbin/init"]