maxhallinan maxhallinan - 4 months ago 30
Node.js Question

Docker container has no TMPDIR environmental variable

I'm running a Node app on node:6.3-wheezy. I noticed that

os.tmpdir()
returns the path to the project directory, which is probably just
PWD
. When I run
env
in the container, I see that there is no
TMPDIR
environmental variable. Why is this? I'd like the system to establish it's own temp directory rather than setting it myself.

Answer

Because you haven't set TMPDIR.

The only environment variables docker will set are

  • HOME - Set based on the value of USER
  • HOSTNAME - The hostname associated with the container
  • PATH - Includes popular directories, such as : /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • TERM - xterm if the container is allocated a pseudo-TTY

Anything else is image specific and up to you.

You can set them via an ENV step in a Dockerfile if needed.