Nextcloud, Technology, Tutorial, Ubuntu

MANUALLY CREATING A MULTI-CONTAINER POD NETWORK WITH PODMAN

What is this?

This is an off-shoot blog from my journey of trying to set up multiple podman containers on an ubuntu server running on my old laptop. This post is very specific about connecting the pods and the network together, not actually setting up the containers and their services. I’ll try to post links to those if I have time or you can search back as I plan on doing one for n8n and nextcloud if I can (they were my test pods). Anyways, assuming you have your caddy container and your services container ready to go (ie. Nextcloud with mariadb), here’s what worked well for me in the end:

  1. Make sure all your services are setup and working first. Let’s take Nextcloud with Mariadb as an example. Make sure the containers are up (ie. with podman compose up -d) and the podman logs <containerName> are showing ‘healthy’. Now spin them back down again as we want them to re-join but on our ‘group network’. Note: you ‘may’ need to actually purge your previous container stuff if you have problems, like I did, but hopefully your previous work won’t mess this up. Ok, everything is now spun down…
  2. Manually create the group-shared network called ‘proxy_net’:

podman network create proxy_net

Make sure it’s listed:
podman network ls

  1. In your compose file (if you are using them) make this is at the bottom declaring “I, Mr. Podman-Compose, shall not create a network automatically like I normally do, because ‘proxy_net’ has already been created externally and Nextcloud shall join that one instead.”:
networks:
  proxy_net:
    external: true
  1. Add networks to public-facing services (like Nextcloud):
networks:
      -  proxy_net
      -  nc_net

This example shows Nextcloud will create an internal network called nc_net and also join the previously manually-created network called proxy_net that we did with the command above. Note: don’t assign proxy_net to databases like mariadb as they should only use the internal network (nc_net)

Repeat this in the compose files for other pods you are doing, if applicable, but I strongly advise not bothering with a second pod until your first one is working successfully.

  1. Spin up Caddy (to make sure it’s ready for traffic)
  2. Confirm Caddy’s container name with podman ps. Let’s assume it is ‘caddy’.
  3. Check logs to make sure Caddy appears to be working ok: podman logs <caddy>
  4. Spin up Pod 1 (ie. Nextcloud) podman-compose up -d
  5. Confirm container name with podman ps. Let’s assume it’s ‘nextcloud_app’ and ‘mariadb`
  6. Check logs to make sure they are running ok:

podman logs nextcloud_app
podman logs mariadb

  1. Try reaching it from an external browser
  2. Spin up Pod 2 in the same way as above

I found this workflow is helpful and a good habit as you can catch little things as you go instead of spinning everything up and then finding out something is wonky and having to wait all that extra time.

Once you have success here, you can add your second Pod by making the same adjustments as per above, making sure also that your Caddyfile has appropriate adjustments to move traffic to the appropriate container ports. Your second, third, etc Pods need to join the proxy_net in the same way to make sure that Caddy can communicate properly with them.

I hope this framework post helps others enjoy the power of podman and a multi-pod container environment.

Tagged , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *