Ryan Shocker
Ryan Shocker

Reputation: 713

Accessing database that is running inside a docker container?

I have a MariaDB up and running in a Docker container. I want to know how to connect to it from an app running locally (not) in the docker container. How can I open up access?

Upvotes: 1

Views: 2538

Answers (2)

Zeromus
Zeromus

Reputation: 4542

when you call docker run to start your container you can bind a specific port like this

docker run -p your_port:3306

this will make your container accessible on docker_host_ip:your_port and the docker service will take care of forwarding the connection to the right container at the port 3306

Upvotes: 1

user2915097
user2915097

Reputation: 32196

your MariaDB container must publish ports, and you will connect using those ports. See for example http://amattn.com/p/installing_maria_db_mysql_with_docker.html

the port 3306 in the container will be mapped to a port on the host, and you will connect to that port.

Upvotes: 1

Related Questions