Open dradtke opened 7 years ago
I actually just realized that there may be some security implications with this change, but it could be minimized by disallowing traversal outside of the specified directory. It also wouldn't play the best with the environment that's set up for a task, but that may or may not be very important.
IIUC, isn't it's something that can be achieved as
config {
command = "/bin/bash"
args = [
"-c",
"cd /my/work/dir && exec $@",
"my-executable"
]
}
?
This worked for me:
"Config": {
"args": [
"-c",
"cd /my/work/dir && my-executable arg1 arg2 ..."
],
"command": "/bin/sh"
}
How do we propagate kill signal to the application when we execute binary like this ?
"Config": { "args": [ "-c", "cd /my/work/dir && my-executable arg1 arg2 ..." ], "command": "/bin/sh" }
I think you can do that by prefixing your executable with exec
, e.g.
"Config": {
"args": ["-c", "cd /my/work/dir && exec my-executable arg1 arg2 ..."],
"command": "/bin/sh"
}
The idea is to have the shell process actually replace itself with your executable, rather than create a separate subprocess.
Is this going to be enhanced in the future? Because certain legacy windows application requires to be run with executing directory = .exe directory.
I know it can be workaround with command = "powershell"
, then traverse directory with args = ["cd ...", ... ]
.
Hi @tgross , Me again. :-) Out of curiosity, do you know if there are any plan regarding this possibility of setting the Working Directory of the raw_exec driver?
We have a case where we need to set(it is about a legacy application which demands to work on a specific dir)... So far we do alternatives libe cd "path" && run
, but would be very nice if we would be abble to set it from the driver.
BR Pedro
We don't have it on our "coming soon" roadmap. So beyond that I couldn't really say when to expect this sort of thing. We'd definitely be open to a PR for it though!
All clear. thanks for the heads up!
Just ran into this problem today. Would love to have this feature.
I have the same issue when running a nodejs app, it would be great to have a working directory setting
Internal ref: https://hashicorp.atlassian.net/browse/NET-10162
The
exec
andraw_exec
drivers should be able to configure the working directory just like thedocker
driver can.