Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to Docker container running mysql on Windows 10

I am using Docker for Windows, on Windows 10 Enterprise. I am trying to connect to a container that is running mysql. I followed the instruction here https://hub.docker.com/_/mysql/ and I used this command to start the container docker run --name memories -e MYSQL_ROOT_PASSWORD=password -d mysql:5.6

if I type docker ps I get

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
300248b56399        mysql:5.6           "docker-entrypoint.sh"   About an hour ago   Up About an hour    3306/tcp            memories

However I cannot figure out how to connect to this container from the host. I have tried localhost and 127.0.0.1. Each time I get an error like this

/* Connecting to 127.0.0.1 via MySQL (TCP/IP), username root, using password: Yes ... */
/* Can't connect to MySQL server on '127.0.0.1' (10061) */

Any suggestions?

like image 768
ryanmc Avatar asked Sep 28 '16 20:09

ryanmc


1 Answers

I guess it was more simple than I thought. I had to publish port 3306

docker run -p 3306:3306 --name memories -e MYSQL_ROOT_PASSWORD=password -d mysql:5.6

like image 192
ryanmc Avatar answered Oct 18 '22 15:10

ryanmc