Closed jnovack closed 3 years ago
vcsim uses Go's ioutil.TempDir, which uses os.TempDir - based on that, the container would need env TMPDIR
set or the /tmp
directory to exisit.
Thank you dougm. Just to document for future archeologists, the following DOES work.
FROM golang:1.14 as build
WORKDIR /go/src/app
RUN CGO_ENABLED=0 go get -u github.com/vmware/govmomi/vcsim
FROM scratch
ENV TMPDIR=/tmp
COPY --from=build /tmp /tmp
COPY --from=build /go/bin/vcsim /vcsim
ENTRYPOINT ["/vcsim"]
For Docker Seamen or Docker Cadets, you cannot mkdir /tmp
in the scratch container because there is no OS. Thus, you must copy it.
For those who run applications in containers as non-root, you must chown
the /tmp
directory on copy into the scratch
container for it to work.
COPY --chown=appuser --from=build /tmp /tmp
Is it ok to close this issue @jnovack ?
@embano1 as soon as the PR is merged.
In a
scratch
container there is no/tmp
directory.https://github.com/vmware/govmomi/blob/cfbe1d59b449be9b5378251bc6e52c65bc5e1cbd/Dockerfile.vcsim#L1-L4
The following
Dockerfile
fails withstat /tmp: no such file or directory
Copying over the
/tmp
directory (for fun), I get: