12

OH MY GOD DOCKER I JUST WANT NODE TO CONNECT TO THE DAMN MYSQL CONTAINER!

its probably easy but jesus there is so much weird documentation to go through and hope something works...

Comments
  • 1
  • 0
    Linking becomes more easy if you use docker-compose.

    You have to link the mysql container to the node app container. It's a pain doing this via `docker run`
  • 0
    Use docker-compose and link both services. The you can use the name as the ip of the other service, and you can connect .
  • 1
    Read the docs. It will help you a lot. Also Docker-compose.
  • 0
    @ManuLG I am using docker-compose, but the link feature seems to be deprecated
  • 0
    @SpectralKH try version 2 of docker compose, it's slightly easier to understand
  • 1
    Try to use container networking if you can, since container links are marked as deprecated. If you create your own bridge network (docker-compose does that for you) you can just use container name resolution to connect to other containers.
  • 1
    Docker compose is my new girlfriend. Everything is simple with her, she made me love docker even more.
  • 0
    @thiemok I am using compose, but I get "connection refused" when I use file_get_contents("http://api") in my PHP container, where api is the name of the node container.

    Also tried setting up user-defined networks simply by defining them and adding all services to it.
  • 1
    @SpectralKH Does your nose application export port 80?
  • 0
    I have the same problemen ffs.
  • 1
    @SpectralKH on which port is your node service running? And did you expose it in your Dockerfile?
  • 3
    @k0pernikus @thiemok I don't know what to feel... I've spent like 6 hours figuring this out (Thank you)
  • 1
    @SpectralKH that's normal ^^
Add Comment