I tried to build a mysql image with dockerFile. Following is my code:
FROM ubuntu
MAINTAINER jimmy
#install mysql
RUN apt-get update
RUN apt-get install -y mysql-server
RUN apt-get install -y mysql-client
RUN apt-get install -y libmysqlclient-dev
#set permission of mysql
RUN service mysql stop
RUN usermod -d /var/lib/mysql/ mysql
RUN chown -R mysql:mysql /var/lib/mysql
When I run docker build -t mysql-test . --no-cache it will build a image successfully.
But if I build a container and inside it, then run service mysql start, it will fail.
* Starting MySQL database server mysqld [fail]
I have to type chown -R mysql:mysql /var/lib/mysql again, inside the container, so that service mysql start can be run successfully.
Why is that? I already RUN chown -R mysql:mysql /var/lib/mysql in dockerFile isn't it?