elfensky
elfensky
PPrisma
Created by elfensky on 12/22/2024 in #help-and-questions
How do I connect to mysql on host from inside a docker container?
can't mark as solution, app did not respond
7 replies
PPrisma
Created by elfensky on 12/22/2024 in #help-and-questions
How do I connect to mysql on host from inside a docker container?
Okay so for any future people: 1. sudo ufw allow from 172.17.0.0/16 to any port 3306 to whitelist the default docker bridge network and allow it to access port 3306 (mysql) 2. docker compose creates a unique network unless you manually specify to use the default docker bridge network. This is how my docker-compose ended up looking like: Note the "network_mode" and "extra_hosts:" sections
services:
h1api:
image: elfensky/h1api:latest # Replace with the correct image name and tag
container_name: h1api # Optional: name your container
env_file:
- .env
ports:
- '52001:3000'
restart: unless-stopped # Automatically restart the container unless it is explicitly stopped
network_mode: bridge # Use the default, ufw-whitelisted Docker Network
extra_hosts:
- "host.docker.internal:host-gateway" # pass the host to container, required on linux
services:
h1api:
image: elfensky/h1api:latest # Replace with the correct image name and tag
container_name: h1api # Optional: name your container
env_file:
- .env
ports:
- '52001:3000'
restart: unless-stopped # Automatically restart the container unless it is explicitly stopped
network_mode: bridge # Use the default, ufw-whitelisted Docker Network
extra_hosts:
- "host.docker.internal:host-gateway" # pass the host to container, required on linux
7 replies
PPrisma
Created by elfensky on 12/22/2024 in #help-and-questions
How do I connect to mysql on host from inside a docker container?
I havent yet, but I at least know where to look. Still need to figure out how to configure docker and firewall to play nice with eachother.
7 replies
PPrisma
Created by elfensky on 12/22/2024 in #help-and-questions
How do I connect to mysql on host from inside a docker container?
omg it was ufw being ass. now I need to figure out the rules, but disabling it seems to have fixes my issues
7 replies