4

so I'm really new to docker and I may be using it incorrectly here but it makes spinning up a mysql database REALLY easy so thats why I wanted to give it a shot rather than installing an instance on my remote (on LAN) machine.

So I want to access the MariaDB database from a different/remote machine however everywhere I look it seems to be providing outdated information, (even the official mariaDB documentation) doesnt provide the correct information, I tried what they say and I believe that is only for accessing the container from the same machine it's running on. Any article or *exchange answer I see tells you to go into the bash terminal of the container then change /etc/msql/my.cnf to have bind_address=0.0.0.0 and this is outdated as bind_address isnt even in my.cnf anymore it's located in /etc/mysql/mariadb.conf.d/50-server.cnf and in there there is a line that states

# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.

I also couldnt find any refrence to an enviroment variable I could set in order to allow me to access it remotely so I really don't know where to look anymore about how to change the configuration in order to allow me to access the data base from my network.

And yes I have a user setup to allow remote connections. Any and all help is appreciated.

On a side note, it seems to be really hard to change this so it makes me believe this is bad practice or to be avoided and then that makes me believe I'm understanding docker wrong, I thought docker was supposed to allow you to run small instances of software that dont interact with each other so if one instance gets screwed up the rest dont but why are they so intent on not allowing a remote connection?

danblack
  • 8,258
  • 2
  • 12
  • 28
user1884295
  • 43
  • 1
  • 3

2 Answers2

1

danblack already answered your question, but I'd like to point out that you probably shouldn't let your container communicate with the host system. Your doubt that this is a bad practice is correct, in my opinion.

What are you trying to do? Connecting your database manually? It's easy to do that. Run:

docker exec -ti <container_name> mariadb -u<user> -p<password>

Or do you want an application to use MariaDB? In that case, the application should run in a container. MariaDB container and the application container should access the same Docker network. This may be a bit tricky for a Docker beginner, but you can automate containers creation and maintenance with Docker Compose.

Federico Razzoli
  • 1,769
  • 9
  • 24
0

The configuration of listening to remote connections is outside the container.

The container default configuration of mariadb listens on all interfaces within the container.

The docker/podman -p or -P is required to expose those interfaces to the host running the container.

If external connections are required listening to a non-local IP (part of -p, which by default will bind to all interfaces). Additionally firewall and routing configurations are required and may not be the default.

danblack
  • 8,258
  • 2
  • 12
  • 28