A short introduction to the use case:
I am using a docker
container to run my go
tests using go test ./...
. This can be achieved easily using docker exec <container> /bin/sh -c "go test ./..."
. Unfortunately go test ./...
runs across all subdirectories and I'd like to exclude one (the vendor directory).
The advised solution for this is using the following command: go test $(go list ./... | grep -v '<excluded>'
, somehow this leaves me with the following result:
docker run golang:1.6.2-alpine /bin/sh -c "go test "
(I have tested this on both run and exec, but they probably use the same core).
When I ssh into the container using docker exec -it <container_id> /bin/sh
and run the exact same command, it works like a charm.
It seems that executing shell commands trough the docker exec/run does not support any commands nested with $()
?
$(go list ./... | grep -v '<excluded>'
, what's<excluded>
is?vendor
for example.$(...)
was expanded by your shell inside double quotes before it was run inside docker container. So, the issue may come from your current directory content. Diddocker exec container /bin/sh -c 'go test $(go list ./... | grep -v "<excluded>")'
work?