I'm trying to instantiate a mysql container with a /var/lib/mysql/ directory with proper permissions and ownership for COPY binding the sql dumps from my old mysql server. But with /var/lib/mysql/ having its permissions and ownership as-is, the container exits upon mount. So I am trying to alter the permissions and ownership of this directory upon instantiation of the container. But this is proving difficult ...
Target: rwxr-xr-x mysql:root /var/lib/mysql
Configuration:
Dockerfile: FROM mysql/mysql-server
RUN chmod 755 /var/lib/mysql
RUN chown -R mysql:root /var/lib/mysql/Images: REPOSITORY TAG IMAGE ID CREATED SIZE
wat 1.0 09edc2e9d91d About an hour ago 381MB
mysql/mysql-server latest 716286be47c6 2 months ago 381MBdocker-compose.yml: version: "3"
services:
mysqlmysql-server:
image: wat:1.0
container_name: mysqlmysql-server
Processing ...
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b21339cf2986 wat:1.0 "/entrypoint.sh mysq…" 11 minutes ago Up 11 minutes (healthy) 3306/tcp, 33060/tcp mysqlmysql-server
b21339cf2986# ls /var/lib -al | grep -e mysql$
drwxr-x--- 7 mysql mysql 4096 Jun 27 04:06 mysql
This is wrong. I am expecting at least rwxr-xr-x and/or mysql:root by now
Teardown / Square 1 ##
$ sudo docker stop *; sudo docker rm *; sudo docker image rmi *; sudo docker pull mysql/mysql-server
$ sudo docker build --tag wat:1.0 - < mysqlmysql-server/Dockerfile-mysqlmysql-server
Successfully built 2a38f54299d8
Successfully tagged wat:1.0
$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
wat 1.0 2a38f54299d8 About a minute ago 381MB
mysql/mysql-server latest 716286be47c6 2 months ago 381MB
$ sudo docker-compose up -d
$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b94f9e776d78 wat:1.0 "/entrypoint.sh mysq…" About a minute ago Up 59 seconds (healthy) 3306/tcp, 33060/tcp mysqlmysql-server
$ sudo docker exec -it b94f9e776d78 bash
bash-4.2# ls /var/lib -al | grep -e ql$
drwxr-x--- 6 mysql mysql 4096 Jun 27 04:27 mysql