I have container1 (10.1.0.2) on host1 (10.0.0.2) and container2 (10.2.0.3) on host2 (10.0.0.3). I’m trying to set up container2 to access a
mysql server on container1. Containers are on bridged networks and cannot be directly accessed outside its respective host. In my attempt, I made the following steps:
/etc/mysql/conf.d/mysqld.cnfon container1 to read
port 3326 # ... bind-address 0.0.0.0
restarted mysql service.
2. Added a proxy device to container1 on host 1:
bash $ lxc config device add container1 p3326 proxy listen=tcp:0.0.0.0:3326 connect=tcp:127.0.0.1:3326
- Allowed port 3326 on both host1 and container1:
bash $ ufw allow 3326 bash $ ufw reload
- Added remote user
mysql> create user 'user'@'container2.lxd' identified by 'password';; mysql> grant all on *..* to 'user'@'container2.lxd'; mysql> flush privileges;
- Try to connect on host2:
bash $ mysql -u 'user' -p -h '10.0.0.2:3326'
And I get:
ERROR 2005 (HY000): Unknown MySQL server host '10.0.0.2:3326' (22)
I thought the proxy device would have routed all traffic on port 3326 to container1, what did I do wrong here?