Docker run failed for MySQL container with permission errors when using a volume - Catalina MacOS X

1.3k views Asked by At

I am running the following command from the mac os x Catalina terminal:

docker run -p 13306:3306 --name mysqltest -e MYSQL_ROOT_PASSWORD="password12" --volume /usr/local/mysql_data:/var/lib/mysql -d mysql:latest 

I get the following error on the console screen:

docker: Error response from daemon: pull access denied for run, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.

This command runs and works if I run it without the --volume or -v option.

Also, if I run from the Docker dashboard with the volume option set I see the following error on the logs screen:

2022-04-12 19:44:03+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.28-1debian10 started.
chown: changing ownership of '/var/lib/mysql/': Operation not permitted**

This seems to indicate a permissions issue but I did add this path to the resources->file sharing in the docker dashboard. I saw a few articles indicating an issue with the Catalina and Docker but did not find a fix for the issue.

1

There are 1 answers

0
paltaa On

So, according to the documentation all attached volumes will be with :rw by default, after a few tests I could see in mac it is not that way, so add :rw to the volume and it will work

docker run -p 13306:3306 --name mysqltest -e MYSQL_ROOT_PASSWORD="password12" --volume /usr/local/mysql_data:/var/lib/mysql:rw -d mysql:latest

Also works with named volumes:

docker run -p 13306:3306 --name mysqltest -e MYSQL_ROOT_PASSWORD="password12" --volume mysql_data:/var/lib/mysql -d mysql:latest