-
Hello, can I somehow pass a service (specifically a database connection) to a Docker action? When I try to pass options like this:
and use this information inside my entrypoint.sh file I get the following error:
Is there any possibility to map the connection? Or do I need to setup MySQL inside my Docker container? Thanks for your advice, Axel |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
There are some of the possible causes of this error:
You can try using ping command to test the client-server connectivity, such as “ ping 127.0.0.1 ”. The following are two Docker container actions for MySQL and docs for MySQL image, maybe you can reference them: |
Beta Was this translation helpful? Give feedback.
-
I already have a MySQL server setup like this:
But my special use case is that I do not want to use it directly in the workflow, but within a docker action used by the workflow. I will try to use the default mysql available in virtual environments instead. |
Beta Was this translation helpful? Give feedback.
-
This thread at stack overflow contains several possible solutions: Is it possible with GitHub actions to call a docker image in host mode by setting/appending
? |
Beta Was this translation helpful? Give feedback.
-
All containers (job, service, actions) get attached to the same user defined bridge network on the host, meaning all the containers can reach each other over that network, not via the host’s localhost networking. From inside your action, you should be able to connect to mysql with hostname mysql (comes from the name of your service) and the default port |
Beta Was this translation helpful? Give feedback.
-
Thank you very much! I’d never found this by myself. |
Beta Was this translation helpful? Give feedback.
-
If I wanted to connect to a remote webdriver from inside a GitHub Action, after running
what address should I use rather than
|
Beta Was this translation helpful? Give feedback.
-
You could run the webdriver as a service container, in which case youd do something like:
That way a docker network will be created, and from inside a container action, you can connect to it via the hostname “selenium” (comes from the service name). So youd just use hostname=selenium, port=4444 Note that in the above example, no port mapping were specified, thats because for user defined bridge networks in docker, all ports are accesible by default, so the application inside the container only needs to actually be listening on 4444 … We dont currently support adding docker-specific options, like “network”, when running container actions so unfortunately you wouldnt be able to create a network, and run your action attached to that network specifically (something like docker run --network …) Of course if you are using a javascript action that would be running on the host, so you could connect via localhost (if you ran the selenium container with --network host) Hope that helps |
Beta Was this translation helpful? Give feedback.
-
What if we have a custom docker container and cannot run it as a service? How can we connect to it?
|
Beta Was this translation helpful? Give feedback.
All containers (job, service, actions) get attached to the same user defined bridge network on the host, meaning all the containers can reach each other over that network, not via the host’s localhost networking. From inside your action, you should be able to connect to mysql with hostname mysql (comes from the name of your service) and the default port