Docker and MariaDB setup questions

Hey folks! I’m working on setting up a fresh VW instance (latest - 1.33.2) in a Docker container. Using the stock sqlite DB I’ve successfully set it up using (non-containerized) Apache to reverse proxy it, and have confirmed it’s visible in-browser where it’s supposed to be.

I’m now looking to instead use an existing non-containerized MariaDB instance on the same physical machine as my DB backend, and I’m having some trouble connecting to it. Prior to this I’ve set up an empty db and a new user with appropriate permissions to the new db, and can confirm through DBeaver that the db is visible using those credentials.

To fire things up I’m using docker compose with environment variables supplied through a .env file - in the .env file I’m providing the DATABASE_URL variable like so:

DATABASE_URL=mysql://username:p%25assword@192.168.1.255:3306/dbname

(possibly importantly, the password includes one or more special characters that I believe I’ve %-escaped correctly - but if there are any characters that are always an Absolute No-No I’d love to know!)

Upon firing up the container with docker compose up -d --force-recreate && docker compose logs -f, I expect Diesel to connect to the DB and begin populating it with all the right stuff via the migration scripts (right?..) but the DB stays unpopulated, and I see the following repeating error in my log file:

[(big long datetime)][vaultwarden][ERROR] Error creating Database pool: DieselCon.
[Cause] BadConnection(
    "Can't connect to server on '192.168.1.255' (115)",
)

To check some things off, I’ve also tried 127.0.0.1 and localhost instead of 192.etc, also with the same result - I believe I saw that I should use the 192.etc address to hit a non-containerized MariaDB from within a Docker container but wanted to confirm.

Any idea what might be going wrong? Thanks in advance o7

I’m running my Vaultwarden in a Docker container using MariaDB in a separate Docker container. My DATABASE_URL is pretty much the same, except no special characters in the password.

Are you really using .255 as the IP? Typically that’s the broadcast address for the subnet (unless you’re doing some sort of subnet masking, I’m by no means a networking expert).

Hi! what address does MariaDB listen? Can you show the entire docker-compose.yml file? For testing, I recently set up the same configuration, and it worked for me.

Sorry for the long wait! Got on to other projects and forgot I’d sent out an ask here.

Good question, I’m not using .255 as the IP - real-life IP is the machine’s local network address.

Appreciate your patience!

  • MariaDB is listening on port 3306 - confirmed to work in theory as I have another web service (NOT in a Docker container!) That I’ve set up on the same machine with the same MariaDB instance as its backend and it’s running happily.

  • compose.yaml is as follows:

services:
    vaultwarden:
        image: vaultwarden/server:latest
        container_name: vaultwarden
        restart: always
        env_file: vaultwarden.env
        volumes:
          - ./data:/data
        ports:
          - 8001:80

The associated vaultwarden.env file, placed in the same directory as compose.yaml, is:

DOMAIN=https://sample.domain.domain
DATABASE_URL=mysql://username:p%25assword@192.168.1.255:3306/dbname
LOG_FILE=/data/vaultwarden.log
LOG_LEVEL=error
SIGNUPS_ALLOWED=false
INVITATIONS_ALLOWED=true

Structurally it seems like everything is in place correctly other than the MariaDB connection, as falling back to the default SQLite backend works fine.

Thanks in advance o7

Another long shot, but I have my .env file in the same directory as the docker compose file too yet specifically put the explicit path to it in compose.yaml.

vaultwarden:
    container_name: vaultwarden
    hostname: vaultwarden
    image: vaultwarden/server:latest
    ports:
      - 8899:80/tcp
    env_file: /volume1/docker/vaultwarden/docker-compose.env
    environment:
      - TZ=America/New_York
    volumes:
      - /volume1/docker/vaultwarden/config:/data:rw
    network_mode: synobridge
    restart: unless-stopped

Solid suggestion - but I am getting logfile entries and its complaints about bad connections do mention the server location from my .env file’s connection string, so it looks like it is getting correctly referenced.

I do see you have a network_mode set while I do not - anything I might be missing in that vein?

I’m running Docker on my Synology NAS so I have that there to indicate which network bridge the container is using. Not sure if that would apply to your setup.