1

I am running an app from a docker container and at some point, I had Sequel Pro connected to my local DB but since reinstalling Sequel Pro, I haven't had luck connecting back to my local DB. Where would I find the IP/port to use for this? I tried connecting to 127.0.0.1 and also tried using the IP address listed in docker inspect (container name) to no avail.

herkypam
  • 75
  • 2
  • 11
  • 1
    Is the database running directly on the host, or in a sibling container? – David Maze May 01 '19 at 16:11
  • it's a sibling container. – herkypam May 01 '19 at 16:58
  • If it's running in a container, do `docker exec -it container-name /bin/bash` where container-name is the container name listed in `docker ps` – noot May 01 '19 at 17:18
  • @nootdev then what though? I want to be connect to the DB on Sequel Pro again. I had it but lost the settings because I had to uninstall the program a few weeks ago. – herkypam May 01 '19 at 19:45
  • You need to expose the port locally then, if you're using, you can do this by using `EXPOSE 3306` in your `DockerFile`. One the port is exposed, you should be able to connect to it via `localhost` – noot May 02 '19 at 15:00

1 Answers1

0

If you address localhost (or 127.0.0.1) inside your container you refer to the localhost inside the container, not the system.

You can use docker networks. If you run the container in the same network (manually adding or with a compose file) you can address like service name:port inside the network. Ports does not have published outside for this (but useful if you want to rech your DB from your system).

A alternativ way is to run your container in network mode host. In this case you run on the network interface of the docker deamon und can use localhost. But you lose some of your isolation.

Wie
  • 422
  • 4
  • 20