act icon indicating copy to clipboard operation
act copied to clipboard

Bind a specific directory of my host machine inside docker, not just the current directory (--bind)

Open intrd opened this issue 2 years ago • 6 comments

Act version

act version 0.2.35

Feature description

Using --bind we can bind the current working dir inside the docker, but I didn't find a way to stay in my working dir and mount a specific directory of my host machine inside a docker path, something like –name=myproj -d -v ~/myproj:/home/user/projects/myproj/ docker command line syntax.

Btw, Is there any way to configure the docker command line through act? or.. pre-configure a mount point on the used image?

Thank you guys.

intrd avatar Jan 05 '23 23:01 intrd

This would be quite useful, for instance if you want to mount ~/.aws/ from host machine so we don't need an additional step in workflows to make it work locally, like here: https://github.com/nektos/act/issues/409#issuecomment-1069241315.

erikahansen avatar Mar 18 '23 21:03 erikahansen

I think --container-options "-v ~/myproj:/home/user/projects/myproj/" allows this.

These are raw docker options.

The Docker commands you see in the log are not used to interact with docker. Act uses the docker api server not cli.

ChristopherHX avatar Mar 18 '23 23:03 ChristopherHX

Confirmed this works, doing something similar with .azure dir.

n15831 avatar Apr 25 '23 09:04 n15831

Has anyone gotten this to work in .actrc? I've tried changing line order, with and without =, nothing seems to apply --container-options correctly.

alexandervlpl avatar Jul 30 '25 06:07 alexandervlpl

actrc follows a different syntax, quotes are forbidden, multiple flags in a line are forbidden

Should be similar to this, not tested by me.

--container-options -v ~/myproj:/home/user/projects/myproj/

Only ${ENV_NAME} is replaced in the value.

If you use container: specify the flags there, then the cli side is dropped.

You may need to replace ~ by ${HOME} and if your path contains quotes then quote it

ChristopherHX avatar Jul 30 '25 09:07 ChristopherHX

Thanks, that works! Also with multiple volumes.

alexandervlpl avatar Jul 30 '25 09:07 alexandervlpl