简体   繁体   中英

initialize mysql in host and access in docker container

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 !

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM