Home > Software engineering >  initialize mysql in host and access in docker container
initialize mysql in host and access in docker container

Time:09-28

I am creating very simple database like

mysql -u root -e "CREATE DATABASE IF NOT EXISTS example"

and I want to access it in the doker container like

"mysql://root@localhost/example"

both host and conteiner is ubuntu machine I suppose answer is very simple but I got lost - Thanks !

CodePudding user response:

With docker, all the stuff can be accessible with localhost. But you need to expose the service to a local port.

So with -p 80:80 in your run command, you will be able to expose the port 80 on your container, to your local port 80.

Docker run doc

I hope it will help you!

  • Related