-
Notifications
You must be signed in to change notification settings - Fork 964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to provide command-line arguments to runner service containers #2139
Comments
Hey @mrparkers, If you are using self-hosted runners, you can leverage runner-container-hooks. With this, you can customize the way docker commands are invoked. For more information, you can find the docs here. |
Hi @nikola-jokic, thanks for your suggestion. Unfortunately, I am not using self-hosted runners for this project, so this solution will not work for me. Do you have any potential workarounds for this using GitHub's hosted runners? |
Hey @mrparkers, Unfortunately, I don't for now 😞 ... Some arguments are added by default, and I don't see an easy workaround. There is an ongoing work related to passing arguments to the ProcessInvoker, and I will keep this issue in mind for that |
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 15 days. |
I ran into this issue as well. It would be nice if we could modify this in the service definition, though there are some other workarounds I've found:
- name: Start docker service on port 3000
id: docker_service
env:
DOCKER_IMAGE: ${{ steps.docker_build.outputs.imageid }}
run: |
{
echo "ENVVAR1=foo";
echo "ENVVAR2=bar";
echo "PORT=3000";
} >> .env
CONTAINER_ID=$(docker run --rm --network host --detach --env-file=.env "$DOCKER_IMAGE")
echo "$CONTAINER_ID"
docker ps
echo "docker_container_id=$CONTAINER_ID" >> "$GITHUB_OUTPUT"
- name: Verify health check
# Or could check docker status to see if container healthy
run: curl --fail -sS --retry 5 --retry-delay 5 --retry-connrefused http://127.0.0.1:3000
# Add steps that depend on service here
- name: Print docker container logs
if: ${{always() && steps.docker_service.outputs.docker_container_id}}
run: docker logs --timestamps ${{steps.docker_service.outputs.docker_container_id}}
- name: Cleanup docker container
if: ${{always() && steps.docker_service.outputs.docker_container_id}}
run: docker stop ${{steps.docker_service.outputs.docker_container_id}} |
Is there still any other way to do this except building docker compose on the host itself for now? |
Also interested in this. For instance, to add extensions to a postgres service container. |
… CI pipeline (#510) For testing support in #300 Note, do to lack of support for adjusting CMD args in service container launching (actions/runner#2139), we basically have to manage starting the container via `docker compose` ourselves. Luckily there are scripts for that already, and this way the CI environment should match the local dev experience as well.
Describe the enhancement
I would like to be able to provide command-line arguments to a service container.
Code Snippet
docker-compose
currently handles this with thecommand
directive:The API for actions could look like this:
Additional information
If you're working with a docker image that only specifies a script as the
ENTRYPOINT
, then there is no feasible way to use this image as a service container within GitHub Actions if you need to specify additional arguments. Here's a list of everything I tried:options
to set the--entrypoint
flag when starting the container, but that doesn't work when trying to set arguments for the entrypoint script.Right now, the only possible workaround is for me to build and push my own container that uses my desired container as a base, and overrides the
ENTRYPOINT
to specify the arguments I want. This is not a good long-term solution, as my test suite runs on three different versions of this software, so I need to maintain three different containers that have this fix.The text was updated successfully, but these errors were encountered: