0

is there any way to connect remote docker container mysql server?

I am installing magento web application, now I have a situation like I need to use/point the existing remote docker container database. I have make port forwarding in order to access database from remote machine but it doe not work.

docker run -it -d -p 3002:80 -h tm.gworks.mobi -v /var/www/public --privileged --name database magedev

For testing purpose in remote machine I have tried like mysql -u root -h 192.168.1.21:3002 -p in mysql console but it does not connect, it throws error ERROR 2005 (HY000): Unknown MySQL server host '192.168.1.21:3002' (-2)

Bilal Usean
  • 2,322
  • 3
  • 22
  • 45
  • I don't know what is wrong with that question. please mention the reason for down vote, otherwise the mistakes is still remain – Bilal Usean Sep 27 '16 at 12:49
  • I'm voting to close this question as off-topic because Stack Overflow is a [programming-related](http://stackoverflow.com/help/on-topic) Q&A site. Your question is not about programming. Perhaps you should post it on http://magento.stackexchange.com instead? – Enigmativity Sep 27 '16 at 13:15
  • 2
    please read once again, this question related to docker not magento. I thought the screenshot confused. actually I need to access remote docker mysql server, thats it. In remote machine we can't mention docker ip as a mysql host so I have make port forwarding but it does not works. Please mention in comment if I wrong I will delete this question. – Bilal Usean Sep 27 '16 at 13:21
  • It's still not about programming. This is a programming forum. You need to post it elsewhere. – Enigmativity Sep 27 '16 at 23:36

1 Answers1

2

Docker run command should be,

docker run -it -d -p 3002:3306 -h tm.gworks.mobi -v /var/www/public --privileged --name database magedev

default mysql port is 3306 but I listen port 80 which is my nginx port so it can't be to allow.

mysql -u root -h 192.168.1.21 -P 3002 -p

now everything works fine

Bilal Usean
  • 2,322
  • 3
  • 22
  • 45