Help connecting to CircleCI MySQL from Docker container?

I’m trying to connect a Docker container to the CircleCI MySQL server as party of the test step so that I can make use of CircleCI’s MySQL instead of having to run a linked Docker container.

I’m using the following argument when running Docker to add the host reference:

--add-host=docker:$(ip route show 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print $2 }')

Unfortunately, which this does add a host into the Docker container, connecting to the MySQL server times out.

Any help would be appreciated.

1 Like

You can run your container with the host network with docker run --net=host imagename, then within the container, you can just connect to 127.0.0.1:3306.

2 Likes