Repository: goss-org/goss

Issue #329: Parametrization of TMP_DIR needed?
Created: 2018-03-12T17:19:58Z
I had problems with my CI integration. When dgoss runs my container it cannot access to mounted directory files.
I have this CI configuration:
image: docker:latest

services:
  - docker:dind
test:
  stage: test
  script:
    - apk add bash curl --no-cache
    - curl -fsSL https://goss.rocks/install | sh
    - docker pull "$CI_REGISTRY_IMAGE"
    - dgoss run "$CI_REGISTRY_IMAGE"

dgoss fails with output:
INFO: Starting docker container
INFO: Container ID: bbba20c7
INFO: Sleeping for 0.2
INFO: Running Tests
sh: /goss/goss: not found
ERROR: Job failed: exit code 127

Some painful debugging shown that directory mounted as /goss to container with goss binary file is empty while source temporary directory on host /tmp/tmp.XXXXXXXXXX contains correct files.
I put some patches in dgoss script that make temporary directory appear in CWD and problem seems to be fixed. I suppose that mounted directory in gitlab pipelines environment in /tmp is inaccessible in container context.
I suggest you can simply parametrize location of $tmp_dir to fix this issue.

Duplicate issue #624: dgoss doesn't work on MacOS because of private `/tmp`
Created: 2020-09-30T11:41:07Z
Describe the bug
It seems dgoss doesn't work on MacOS because /tmp is private (I guess). I.e. docker cannot see files created by user.
How To Reproduce
Install current dgoss & goss on MacOS as described in documentation and try dgoss edit alpine sleep 1000 e.g. You may see there is no goss binary copied into container. See Actual Behavior for example.
Expected Behavior
It's expected to have /goss/goss binary in docker container.
➜  dgoss edit alpine sleep 1000
INFO: Starting docker container
INFO: Container ID: f1911630
INFO: Run goss add/autoadd to add resources
/goss # ls -la /goss/
total 8332
drwxrwxrwx    4 root     root           128 Sep 30 11:30 .
drwxr-xr-x    1 root     root          4096 Sep 30 11:30 ..
-rw-r--r--    1 root     root             0 Sep 30 11:30 docker_output.log
-rwxr-xr-x    1 root     root       8524064 Sep 30 11:30 goss

Actual Behavior
➜ dgoss edit alpine sleep 1000
INFO: Starting docker container
INFO: Container ID: 389e40a1
INFO: Run goss add/autoadd to add resources
/goss # ls -la /goss/
total 4
drwxr-xr-x    2 root     root            40 Sep 30 11:27 .
drwxr-xr-x    1 root     root          4096 Sep 30 11:27 ..

Environment:

goss version v0.3.6
MacOS Mojave 10.14.6 (18G6020)

How to fix
I fixed it for myself by applying the following change. Actually I'm just using ~/tmp instead of /tmp. I'm not sure it's good solution for everyone though.. I'd prefer to be able to override it via environment variable.
➜  diff -u dgoss.orig dgoss
--- dgoss.orig	2020-09-30 19:30:28.000000000 +0800
+++ dgoss	2020-09-30 19:30:37.000000000 +0800
@@ -66,7 +66,7 @@
 }

 # Main
-tmp_dir=$(mktemp -d /tmp/tmp.XXXXXXXXXX)
+tmp_dir=$(mktemp -d ~/tmp/tmp.XXXXXXXXXX)
 chmod 777 "$tmp_dir"
 trap 'ret=$?;cleanup;exit $ret' EXIT

Closing comment (2020-10-04T16:52:41Z): This seems like a duplicate of #329.
Also, I wonder if it's related to the following:

https://stackoverflow.com/questions/37673140/docker-volume-located-in-tmp-on-osx-empty
https://stackoverflow.com/questions/55667800/mac-docker-volume-mount-using-osxfs-not-working

I wonder if there's a way for dgoss to detect this.