How to Connect Docker Containers?
I'm still fairly new to the Docker game, too, but I've got a few little projects that I do exactly what you are asking about. Through my own experience with trial &amp; error (mostly error...) I would suggest using a docker-compose.yml with your network set to static internal IPs so each container will have predictable, repeatable results and IPs that you can configure your containers to communicate across.
I'm not familiar with BaseX but I have a sample situation using docker-compose version: &quot;3.7&quot; here that could easily run multiple apps and/or be added to or repurposed to fit your hypothetical.
This example docker-compose has the following:

A separate container for populating my app-volume volume with the contents of a public GitHub repo.

An Apache Web Server container with PHP-FPM enabled for a &quot;selective backend&quot; that gets built from a Dockerfile in the ~/dockerbuild directory.

An nginx web server container used as a reverse proxy for all things PHP to be passed to Apache (but serves &amp; caches pretty much everything else).

A MariaDB container in the mix for the app DB that I populate with a mysqldump file after the app gets built.


This is a slimmed down version of my docker-compose.yml, so note that you can add a variety of things like healthcheck: and command: to fit your needs.
You execute with docker-compose up -d --build to both build and start your app in one command (but you'll probably want to create your own ba(.sh) file that you execute afterwards, too for those important finishing touches).
Take notice of static-network. And while I am using named volumes in the example, that's just a preference of mine.
version: &quot;3.7&quot;

services:

  github_repo_clone:
    image: debian:latest
    container_name: github_repo_clone
    networks: 
      static-network:
        ipv4_address: 172.20.0.254

    command: bash -c &quot;
        apt-get update &amp;&amp; 
        apt-get install git -y &amp;&amp;
        rm -rf examplerepo &amp;&amp;
        git clone https://github.com/exampleuser/examplerepo.git &amp;&amp;
        rm -rf /var/www/vhosts/exampleuser/examplerepo &amp;&amp;
        mkdir -p /var/www/vhosts/exampleuser/examplerepo &amp;&amp;
        cp -rapv examplerepo/* /var/www/vhosts/exampleuser/examplerepo &amp;&amp;
        rm -rf examplerepo &amp;&amp;
        tail -f /dev/null
      &quot;
    volumes:
     - app-volume:/var/www/vhosts

  apache_php-fpm_backend:
    container_name: debian-build-demo0
    build: ~/dockerbuild
    ports:
     - &quot;8080:8080&quot;
    networks:
      static-network:
        ipv4_address: 172.20.0.2
    volumes:
     - app-volume:/var/www/vhosts


  nginx_rp:
    image: nginx:latest
    container_name: nginx-build-demo0
    ports:
     - &quot;80:80&quot;
     - &quot;443:443&quot;
    networks:
      static-network:
        ipv4_address: 172.20.0.3
    volumes:
     - app-volume:/var/www/vhosts

  mariadb:
    restart: always
    image: mariadb:latest
    container_name: mariadb-build-demo0
    ports:
     - &quot;3306:3306&quot;
    networks:
      static-network:
        ipv4_address: 172.20.0.10
    environment:
     - MYSQL_ROOT_PASSWORD=4007p@$$w04d
     - MYSQL_USER=dbusernamegoeshere
     - MYSQL_PASSWORD=@p@$$w04d
     - MYSQL_DATABASE=dbnamegoeshere
    volumes:
     - app-volume:/var/www/vhosts
    healthcheck:
      test: [&quot;CMD&quot;, &quot;mysqladmin&quot; ,&quot;ping&quot;, &quot;-h&quot;, &quot;localhost&quot;]
      timeout: 10s
      retries: 5

volumes:
  app-volume:
#    external: true

networks:
  static-network:
    driver: bridge
    ipam:
      driver: default
      config:
       - subnet: 172.20.0.0/16


My clean up command when I take the app down is kind of ugly, but not terribly difficult to read and goes something like this:
docker-compose down -v ; docker rmi -f dockerbuild_apache_php-fpm_backend:latest mariadb:latest nginx:latest debian:latest ; docker rmi -f $(docker images -q --filter &quot;dangling=true&quot;) ; docker rmi -f $(docker images -q --filter label=stage=intermediate) ; docker volume prune -f; 
I think each &quot;independent app&quot; could (and probably should) have its own docker-compose and/or Dockerfiles, but you may find synergies with certain Dockerfiles that you can create custom command: instructions for (such as the git_repo_clone example) to be used &amp; shared across multiple &quot;apps&quot;.