Access Host Podman Container in Distrobox

New to Bluefin/UBlue! So far so good.

I’m setting up a dev environment and I’m installing all my dev tools in a distrobox container.

However, I need to access a MariaDB database from my project in the distrobox container. My initial thought was to run a MariaDB podman container on the host and access that from the distrobox container.

Any ideas on how to get this working? The MariaDB podman container is working fine. I can access the DB via podman exec -ti mariadb mariadb -u root -p mysql. I didn’t specify a network in the docker-compose.yml file so it created a mariadb_default network and it has been assigned 10.89.0.5 address.

How can I access this from the distrobox container? That IP is not available if I try and connect to it via the mariadb command and I cannot ping it.

It appears as though the MariaDB container is running on a separate network than the distrobox container. Any ideas how I can accomplish this?

As a test I set up a container in Incus rather than podman and installed/configured MariaDB and I’m able to connect to that from the distrobox container. I’d prefer to just use a podman container for the database if possible.

Thanks for the assistance!

You could just map a port by spinning up mariadb in this way. Here I use the -p flag and map mariadb’s 3306 port to be accessible to localhost:3306.

podman run \
  --detach \
  --name mariadb \
  --env MARIADB_ROOT_PASSWORD=mysql \
  -p 127.0.0.1:3306:3306 \
  mariadb:latest

Tested in an ubuntu distrobox container running the formulahendry.vscode-mysql plugin in vscode and could connect to the mysql server via port 3306 from the distrobox container and the host machine

Thanks for the reply! If I map port 3306 like this will it be available outside my local machine? Normally in Docker this is the case but in my situation I don’t want MariaDB available outside my machine for security reasons.

EDIT: it appears as though the exposed port is not available externally. I currently have firewalld set to block connections on all ports so perhaps this is why?

Usually with Docker the exposed ports are still available regardless of firewall settings so perhaps podman respects the firewall and it’s ports are being blocked as expected.

Try “-p 127.0.0.1:3306:3306” then it should only be accessible locally.

Perfect! I think this solution will work for my development workflow. Thanks for your help.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.