<div dir="ltr">Hi Andrey. Actually, I should have mentioned this first but I don't mean "share" in the sense of sharing a data-dir with two database instances. Rather, I mean "share" in the context of Host to Container. I will only be running mysql in the container, not the host. So my objective is basically to offer the container mysql a valid data-dir *from* the host. That's it. Is it doable? </div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 9, 2018 at 5:13 PM, Andrey Repin <span dir="ltr"><<a href="mailto:anrdaemon@yandex.ru" target="_blank">anrdaemon@yandex.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Greetings, Tony P!<br>
<span class=""><br>
> What's the correct way to share the mysql/mariadb data dir of the host<br>
> system to a container and map the permissions correctly?<br>
<br>
</span>There's no correct way to *share* the database directory.<br>
Database engine simply do not expect the shared locks in the slightest.<br>
<div class="HOEnZb"><div class="h5"><br>
> I have been<br>
> struggling with this for a couple of days. I'm sorry if this question has<br>
> been asked before, but I have searched thoroughly and not been able to find<br>
> the solution yet. Basically what I have done so far:<br>
<br>
<br>
> Install mariadb-server on both host and container and:<br>
<br>
<br>
> $ printf "lxd:$(id -u mysql):1\nroot:$(id -u mysql):1\n" | sudo tee -a /etc/subuid<br>
> $ printf "lxd:$(id -g mysql):1\nroot:$(id -g mysql):1\n" | sudo tee -a /etc/subgid<br>
> $ sudo systemctl restart lxd<br>
> $ printf "uid $(id -u mysql) 1000\ngid $(id -g mysql) 1000" | lxc config set $CONTAINER_NAME raw.idmap -<br>
> $ lxc restart $CONTAINER_NAME<br>
> $ sudo lxc config device add $CONTAINER_NAME mysql disk<br>
> source=/var/lib/mysql path=/var/lib/mysql<br>
> Unfortunately, this breaks the container and prevents it from starting since the mapping isn't allowed.<br>
<br>
<br>
> $ sudo lxc info --show-log ub1804x64-3<br>
<br>
<br>
> Name: ub1804x64-3<br>
> Remote: unix://<br>
> Architecture: x86_64<br>
> Created: 2018/07/09 15:30 UTC<br>
> Status: Stopped<br>
> Type: persistent<br>
> Profiles: default<br>
<br>
<br>
> Log:<br>
<br>
<br>
> lxc ub1804x64-3 20180709154554.682 ERROR    lxc_conf -<br>
> conf.c:lxc_map_ids:2919 - newuidmap failed to write mapping "newuidmap: uid<br>
> range [1000-1001) -> [114-115) not allowed": newuidmap 6725 0 100000 1000 1000 114 1 1001 101001 64535<br>
> lxc ub1804x64-3 20180709154554.682 ERROR    lxc_start -<br>
> start.c:lxc_spawn:1661 - Failed to set up id mapping.<br>
> lxc ub1804x64-3 20180709154554.755 WARN     lxc_network -<br>
> network.c:lxc_delete_network_<wbr>priv:2607 - Failed to remove interface<br>
> "veth38DOB9" from "lxdbr0": Invalid argument<br>
> lxc ub1804x64-3 20180709154554.755 ERROR    lxc_container -<br>
> lxccontainer.c:wait_on_<wbr>daemonized_start:834 - Received container state "ABORTING" instead of "RUNNING"<br>
> lxc ub1804x64-3 20180709154554.756 ERROR    lxc_start -<br>
> start.c:__lxc_start:1887 - Failed to spawn container "ub1804x64-3"<br>
> lxc 20180709154554.775 WARN     lxc_commands -<br>
> commands.c:lxc_cmd_rsp_recv:<wbr>130 - Connection reset by peer - Failed to<br>
> receive response for command "get_state"<br>
> I'm basically following this article<br>
> (<a href="https://stgraber.org/2017/06/15/custom-user-mappings-in-lxd-containers/" rel="noreferrer" target="_blank">https://stgraber.org/2017/06/<wbr>15/custom-user-mappings-in-<wbr>lxd-containers/</a>)<br>
> written by Stéphane Graber (the super awesome primary LXD developer) to<br>
> achieve this. I'll admit that I don't fully understand what's going on here,<br>
> if someone could help me understand my mistake a bit better, I'd really<br>
> appreciate it. I have a feeling I have the range wrong (1000?). I previously<br>
> attempted doing the same by manually adding the mysql user/group and trying<br>
> to map those (instead of installing mysql), but that also didn't work out<br>
> (Same error). This is what I tried before trying the mapping):<br>
<br>
<br>
> $ sudo groupadd mysql<br>
> $ sudo useradd -r -g mysql mysql<br>
<br>
<br>
> I also tried with: <br>
> $ printf "both $(id -u mysql) $(id -u mysql)" | lxc config set $CONTAINER_NAME raw.idmap -<br>
<br>
<br>
> Then the error I get is:<br>
<br>
<br>
> $ sudo lxc info --show-log tmp3<br>
<br>
<br>
> Name: tmp3<br>
> Remote: unix://<br>
> Architecture: x86_64<br>
> Created: 2018/07/09 20:32 UTC<br>
> Status: Stopped<br>
> Type: persistent<br>
> Profiles: default<br>
<br>
<br>
> Log:<br>
<br>
<br>
> lxc tmp3 20180709204423.805 ERROR    lxc_conf - conf.c:lxc_map_ids:2919 -<br>
> newgidmap failed to write mapping "newgidmap: gid range [114-115) -><br>
> [114-115) not allowed": newgidmap 30081 114 114 1 0 100000 114 115 100115 65421<br>
> lxc tmp3 20180709204423.805 ERROR    lxc_start - start.c:lxc_spawn:1661 - Failed to set up id mapping.<br>
> lxc tmp3 20180709204423.876 WARN     lxc_network -<br>
> network.c:lxc_delete_network_<wbr>priv:2607 - Failed to remove interface<br>
> "vethYL869L" from "lxdbr0": Invalid argument<br>
> lxc tmp3 20180709204423.876 ERROR    lxc_container -<br>
> lxccontainer.c:wait_on_<wbr>daemonized_start:834 - Received container state "ABORTING" instead of "RUNNING"<br>
> lxc tmp3 20180709204423.877 ERROR    lxc_start - start.c:__lxc_start:1887 - Failed to spawn container "tmp3"<br>
> lxc 20180709204423.897 WARN     lxc_commands -<br>
> commands.c:lxc_cmd_rsp_recv:<wbr>130 - Connection reset by peer - Failed to<br>
> receive response for command "get_state"<br>
<br>
<br>
<br>
<br>
> I'm using LXD 3.0.1 running on host Ubuntu 18.04 amd64 and testing with a Ubuntu 18.04 amd64 container<br>
<br>
<br>
> Thanks for your help in advance!!<br>
<br>
<br>
<br>
</div></div><span class="HOEnZb"><font color="#888888">-- <br>
With best regards,<br>
Andrey Repin<br>
Tuesday, July 10, 2018 0:11:53<br>
<br>
Sorry for my terrible english...<br>
______________________________<wbr>_________________<br>
lxc-users mailing list<br>
<a href="mailto:lxc-users@lists.linuxcontainers.org">lxc-users@lists.<wbr>linuxcontainers.org</a><br>
<a href="http://lists.linuxcontainers.org/listinfo/lxc-users" rel="noreferrer" target="_blank">http://lists.linuxcontainers.<wbr>org/listinfo/lxc-users</a></font></span></blockquote></div><br></div>