[lxc-users] LXD share /var/lib/mysql from host to container and map user/group

David Favor david at davidfavor.com
Sat Jul 14 16:16:31 UTC 2018


Tony P wrote:
> Hi David. Those are excellent points. Actually, I regret not mentioning 
> my purpose in the original e-mail. To clarify, I don't intend to run a 
> host mariadb and a container mariadb simultaneously. Also, this is 
> definitely not for production. This is primarily for my development 
> environment. I intend to test my web applications inside various 
> containers which will all have different configurations. The web 
> applications are developed inside the host, and tested with these 
> varying configurations within the containers. However, the dummy 
> development data from the mysql host is always consistent. That is 
> basically the only thing that does not change. I know I could easily 
> copy this data over to the containers and then apply the required 
> permissions that way, but I prefer to implement a "shared" drive/dir 
> instead. Of course, like I said before, only one database server will be 
> running at any given time on the data-dir

Better to do one of these...

1) Run mysql in a container as a database instance, then connect
    to your database container from other containers.

    Problem with this is the same as running host datadir... if you
    ever connect to your database instance from more than one container,
    all bets are off as to if your data will survive.

2) Use LXD as intended.

    Run your entire LAMP stack in a container.

    If you have test data, just load your common .sql file into your
    database instance.

    This way you'll never have to ensure only one client instance
    is talking to your database instance.

LXD is very flexible + will not protect you against destroying your
data, if you work around LXD normal protection schemes.


More information about the lxc-users mailing list