Sunday, September 24, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  1] [ 0]  / answers: 1 / hits: 497  / 1 Year ago, wed, june 22, 2022, 5:24:02

I'm creating a docker container with volume but I can't access the container directory, does anyone know how to solve this?

The command used is this:

docker run --name Mysql -d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -v mysql-data:/var/lib/mysql mysql:latest

More From » 22.04


The issue has to do with directory permissions. The /var/lib/mysql/ directory is owned by mysql. If only a single Docker container will use this directory, you can change its ownership to the same account that operates Docker.

For example:

sudo chown -R rafael:rafael /var/lib/mysql

Doing this will allow the Docker container to access all of the files that currently exist in that given directory, which may be useful if you are trying to ensure MySQL is always a specific version while keeping the core OS up to date with security patches.

[#71] Thursday, June 23, 2022, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 120
Total Questions: 126
Total Answers: 119

Location: Marshall Islands
Member since Wed, Feb 9, 2022
2 Years ago
gavgenerati questions