host.docker.internal is not accessible via GitHub actions. There are two alternative approaches available, as below (which should be documented properly):
-
Use a “container” for the job, which allows a “network-alias” to be configured, which can then be used to access the container (where the booking system resides) from the test suite. Full example here: https://github.com/openactive/OpenActive.Server.NET/blob/feature/docker-image/.github/workflows/docker-test-3.yml
-
Use the static IP of 172.17.0.1, which can be used to access the host (where the booking system resides) from the test suite. This does not require a “container” to be used. Full example here: https://github.com/openactive/OpenActive.Server.NET/blob/feature/docker-image/.github/workflows/docker-test-4.yml
It should be possible to add host.docker.internal within docker-entrypoint.sh if the Docker container is running within a GitHub Action with something like the below, however there are issues with this as /etc/hosts is not available to the non-root user:
# Check if running inside a GitHub Action
if [ -n "$GITHUB_ACTIONS" ]; then
echo "Running inside GitHub Actions. Adding host.docker.internal to /etc/hosts."
echo "172.17.0.1 host.docker.internal" >> /etc/hosts
fi
A more robust solution would be to do something like the equivalent of docker create --add-host=host.docker.internal:host-gateway (where host-gateway replaces 172.17.0.1), within the GitHub action.yml. It's not clear if this is supported.
Additionally it should also be possible to trust host certificates, to allow reference implementation to be fully tested via Docker, as per https://serverfault.com/questions/1150886/docker-giving-container-access-to-hosts-ca-certs
host.docker.internalis not accessible via GitHub actions. There are two alternative approaches available, as below (which should be documented properly):Use a “container” for the job, which allows a “network-alias” to be configured, which can then be used to access the container (where the booking system resides) from the test suite. Full example here: https://github.com/openactive/OpenActive.Server.NET/blob/feature/docker-image/.github/workflows/docker-test-3.yml
Use the static IP of 172.17.0.1, which can be used to access the host (where the booking system resides) from the test suite. This does not require a “container” to be used. Full example here: https://github.com/openactive/OpenActive.Server.NET/blob/feature/docker-image/.github/workflows/docker-test-4.yml
It should be possible to add
host.docker.internalwithindocker-entrypoint.shif the Docker container is running within a GitHub Action with something like the below, however there are issues with this as/etc/hostsis not available to the non-root user:A more robust solution would be to do something like the equivalent of
docker create --add-host=host.docker.internal:host-gateway(wherehost-gatewayreplaces172.17.0.1), within the GitHubaction.yml. It's not clear if this is supported.Additionally it should also be possible to trust host certificates, to allow reference implementation to be fully tested via Docker, as per https://serverfault.com/questions/1150886/docker-giving-container-access-to-hosts-ca-certs