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 & 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: "3.7" 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 "selective backend" 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 & 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
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.
command: bash -c "
apt-get update &&
apt-get install git -y &&
rm -rf examplerepo &&
git clone https://github.com/exampleuser/examplerepo.git &&
rm -rf /var/www/vhosts/exampleuser/examplerepo &&
mkdir -p /var/www/vhosts/exampleuser/examplerepo &&
cp -rapv examplerepo/* /var/www/vhosts/exampleuser/examplerepo &&
rm -rf examplerepo &&
tail -f /dev/null
test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
# external: true
- 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 "dangling=true") ; docker rmi -f $(docker images -q --filter label=stage=intermediate) ; docker volume prune -f;
I think each "independent app" 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 & shared across multiple "apps".