docs icon indicating copy to clipboard operation
docs copied to clipboard

Working Directory with custom images

Open richseviora opened this issue 8 months ago • 9 comments

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/actions/writing-workflows/choosing-where-your-workflow-runs/running-jobs-in-a-container

What part(s) of the article would you like to see updated?

When using a custom image, I've observed that GH Actions appears to be setting the container's work directory to its own custom directory. In my case it's __w/server/server. Therefore, any bash command I would've ran as-is successfully fails until I set the working-directory option to the correct value.

I don't know exactly how that value is being set, though it certainly appears to align with the volume paths captured here.

Additional information

I can confirm that setting the working-directory fixed my problem, but I don't know what's causing the issue and therefore what conditions it presents itself in.

richseviora avatar Mar 21 '25 19:03 richseviora

Thanks for opening this issue. A GitHub docs team member should be by to give feedback soon. In the meantime, please check out the contributing guidelines.

welcome[bot] avatar Mar 21 '25 19:03 welcome[bot]

Thanks for opening an issue! We've triaged this issue for technical review by a subject matter expert :eyes:

github-actions[bot] avatar Mar 21 '25 20:03 github-actions[bot]

@richseviora Thank you for opening this issue! I'll get this triaged for review. ✨ Our team will provide feedback regarding best next steps. Thanks for your patience!

Sharra-writes avatar Mar 21 '25 20:03 Sharra-writes

@richseviora While we're waiting for an SME review, one of the members of the team found this article and wondered if you had read it/if it could help with the problem you're encountering. 💛

Sharra-writes avatar Mar 26 '25 18:03 Sharra-writes

Hi @Sharra-writes! Thanks for that link! This feels related to the issue I encountered. I didn't find it when I first went looking for this issue. ~Given that this article is all about the specific way that GHA uses Docker images, I wonder if it'd make more sense for the documentation in the article I first linked to link to this article?~

... actually, on second thought, I think this article is definitely related to my issue and could have the same root cause, but I think the presentation is a bit different. Which I think is actually a really helpful distinction, at least it is for me and my mental model :)

The article you linked to is written in the context of creating a custom GH action, whereas I'm trying to use a prebuilt image here in a GH workflow. So some of that article's instructions appear to be relevant (like the WORKDIR inhibition), but I think they're not exactly on point because my container is already built and therefore the image could never build incorrectly as it would were the image being built on your servers. It's just not going to be executed correctly b/c the docker create command being run by the workflow is overriding the work dir (see the --workdir option):

 /usr/bin/docker create --name XXX_dkrecruswest2amazonawscomXXX_fadae2 --label 6f0ad1 --workdir /__w/server/server --network github_network_YYY  -e "HOME=/github/home" -e GITHUB_ACTIONS=true -e CI=true -v \
"/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work":"/__w" -v \
"/home/runner/runners/2.323.0/externals":"/__e":ro -v "/home/runner/work/_temp":"/__w/_temp" -v \
"/home/runner/work/_actions":"/__w/_actions" -v "/opt/hostedtoolcache":"/__t" -v \
"/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" --entrypoint "tail" XXX.dkr.ecr.us-west-2.amazonaws.com/sweatrecord-app:XXX "-f" "/dev/null"

I was going to suggest linking to that article, but given that the context is different I'm left wondering whether that's the right thing to do. What do you think?

richseviora avatar Mar 26 '25 19:03 richseviora

@richseviora Thanks for your patience! 💛 We're checking in with our SMEs again to see how to move forward on this. I can't give you a timeframe, but we will let you know what gets decided. Thank you again for bringing up this issue. ✨

Sharra-writes avatar Mar 27 '25 19:03 Sharra-writes

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Apr 25 '25 16:04 github-actions[bot]

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar May 24 '25 16:05 github-actions[bot]

Thanks. So many possibilities: apps and programming with GitHub Copilot.

DirectoryMarket avatar Jun 11 '25 20:06 DirectoryMarket

This is a gentle bump for the docs team that this issue is waiting for technical review.

github-actions[bot] avatar Jul 10 '25 16:07 github-actions[bot]

A stale label has been added to this issue, because it has been open for 30 days with no activity. If you think this issue should remain open, please add a new comment.

github-actions[bot] avatar Aug 12 '25 16:08 github-actions[bot]