• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

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