Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow overriding workdir for container jobs

See original GitHub issue

Describe the enhancement Allow overriding container’s workdir. Currently, even if passing --workdir=/somedir to the container: options: it does not override the first --workdir option passed to docker create by the runner. It would be nice to be able to override the workdir somehow, so that on self-hosted runners, after the job is done the checked out sources would not remain the in actions-runner/_work directory. In container jobs it makes no sense to mount the external directory, as all the job steps are executed within the container anyway. If work dir is set to some in-container directory, then after the job is done the container is discarded and all the build artifacts are discarded as well, no separate cleanup is needed.

Code Snippet

  image: debian:buster
  options: --workdir=/home/build/myrepo

This example currently will result in that --workdir is passed twice to the docker create. The first one is the default one which is --workdir /__w/myrepo/myrepo and the second is the one indicated in options:, but it looks like docker create takes the first one and ignores the second one. So, there is no possibility to override the workdir. Need to exclude the default --workdir option in case options: contains custom --workdir option.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:35
  • Comments:13 (1 by maintainers)

github_iconTop GitHub Comments

yurirocha15commented, Apr 26, 2021

I am having a similar issue. I need to place my code inside a specific directory in order to build it (which is the default workdir in my container). In my opinion, the runner should only set the workdir/HOME if they aren’t set (or provide a way to change the default values).

prashantkalkarcommented, Sep 19, 2022

I am working around this limitation by providing a default workspace for the job. As follows:

        image: ubuntu:20.04
           working-directory: /

Now any steps in the job will run as per new working directory. May be this is useful till the actual solution is implemented.

Note that, the marketplace actions might still work with the GITHUB_WORKSPACE location. So configure the action appropriately.

Read more comments on GitHub >

github_iconTop Results From Across the Web

docker-compose overrides directories in the container
Context. I set up a PHP application recently to work in a docker container connected to a database in a different container. In...
Read more >
Docker Container Jobs in GitHub Actions
I liken it to delegating the entire job to the container, so every step that would run in the job will instead run...
Read more >
What Is the Default WORKDIR in a Dockerfile?
Learn about the default value of the WORKDIR instruction in Docker. ... And the Alpaquita Containers incorporates Liberica JDK Lite, ...
Read more >
Run your CI/CD jobs in Docker containers
GitLab product documentation.
Read more >
WorkdirOverride type
Creating the file for a configuration object of type WorkdirOverride ... run ibmint apply overrides commands against your integration server work directory, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found