• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

Question Networking between Docker containers

davorg

Basic Pleskian
I've been experimenting with Docker. I have an application that is made up of two Docker containers - one has a Perl web application and the other has a MariaDB database.

I've installed both containers using the Plesk Docker extension and I can get them both up and running. I've mapped the MariaDB container's port to 13306 and I can successfully connect to the database from the command line. I've mapped the web application's port to 1702 and I can see the application running on that port, but it only ever throws errors - because it can't connect to the database. I've tried setting the DB host to both "localhost" and "127.0.0.1" and in both cases I get connection errors in the logs.
DBI Connection failed: DBI connect('host=localhost;database=succession;port=13306','succession',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /succession/local/lib/perl5/DBIx/Class/Storage/DBI.pm line 1517.
On my laptop, I have this working successfully, but I had to add --network="host" to the docker run command in order to get it to work. How do I get host networking working on Docker containers running under Plesk?

Alternatively, I have a Docker compose definition that runs successfully, but I can't see any way to run docker-compose under Plesk. Am I missing something obvious?

Thanks for your help.

Dave...
 
Hello, you need to use ip other then localhost or 127.0.0.1. You can't use there IPs because mysql clients routes this requests to local socket and you can not change this (and there are no mysql socket inside your perl container). You can share socket between containers using volumes but i could not suggest this method. Just use your server public ip and port.
You can use docker-compose on plesk server, but it is not supported natively by docker extension yet. So, you need to install docker-compose using this manual Install Docker Compose. Then you can setup internal networking using docker-compose (not exposing mysql port outside, but only for perl internally) and proxy requests from web to perl container using nginx additional server rules. But this method a bit more complicated then first one.
 
Thanks. That makes sense, I guess. But I'd like it more if the Docker extension supported the various inter-containing networking modes that "docker build" supports.

I might look at installing docker-compose. But I think it's more likely that I'll try running this on AWS ECS instead.

Dave...
 
Back
Top