Docker container action does not execute from the repository root
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 6.3k
- Forks
- 1.4k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 24
Description
Describe the bug
I have a dockerfile defined in dockerfiles/compile/Dockerfile.
Github Actions executes Docker from the directory where the Dockerfile is stored:
/usr/bin/docker build -t 4cd98f:f7c0bfc3fa7c515f8b9a964cbb495763 -f "/home/runner/work/hello-world-docker-action/hello-world-docker-action/./.github/workflows/actions/compile/../../../../dockerfiles/compile/Dockerfile" "/home/runner/work/hello-world-docker-action/hello-world-docker-action/dockerfiles/compile"
This causes my go build instruction in my Dockerfile to fail in Github Actions because my source files (namely go.mod) are not found in dockerfiles/compile/Dockerfile.
See this gist for the full log: https://gist.github.com/discentem/4deff7191e527f0210e79fedfaca4026
To Reproduce
Fork https://github.com/discentem/hello-world-docker-action and push this commit to a new branch to trigger CI.
Expected behavior
I would expect Docker to be executed from the root of my repository and not specifically from the directory where the Dockerfile is sourced from. Something like this:
/usr/bin/docker build -t 4cd98f:f7c0bfc3fa7c515f8b9a964cbb495763 -f "/home/runner/work/hello-world-docker-action/hello-world-docker-action/./.github/workflows/actions/compile/../../../../dockerfiles/compile/Dockerfile" "."
Or perhaps there should be a param to tell the runner what directory to run docker in
Workaround
If I copy my Dockerfile to the root of my repository on the fly and point the action to this copy, the action succeeds. This is because the Dockerfile is now being executed in a directory where go.mod and the go source files can be found.
Runner Version and Platform
Hosted, Ubuntu 20.04
OS of the machine running the runner? Linux
What's not working?
Please include error messages and screenshots.
Job Log Output
Runner and Worker's Diagnostic Logs
N/A
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure using dockerfiles/compile/Dockerfile, the referenced workflow compile action, and the provided failed job log. Compare the reported Docker build context with the expected repository-root context; done means the action handles this layout successfully and includes coverage or validation for the corrected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, github-actions, go
- Domain
- ci-cd, devops
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100