-1

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 !

Jakub Mitura
  • 159
  • 1
  • 14
  • Are you looking for the mechanisms described in [From inside of a Docker container, how do I connect to the localhost of the machine?](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach) (More complicated on native Linux.) Can you run the database in a container, alongside the application? – David Maze Sep 27 '22 at 23:38

1 Answers1

1

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!

Max
  • 64
  • 5