How to use env var in WORKDIR stanza?

I have a pretty slim Dockerfile so far:

FROM ubuntu:trusty

ADD mypackage-${MYPACKAGE_VERSION}.tar.gz /root/

The .tar.gz gets properly added to the docker file, (it is automatically extracted which is frustrating as that may not be desirable at all times). so on the image the path /root/mypackage-0.1.2/ exists and contains the content I want to work with, however the WORKDIR stanza cd’s into the literal path /root/mypackage-${MYPACKAGE_VERSION}, escaped as /root/fifechan-\$\{FIFECHAN_VERSION\}/.

  • how to debug container images using openshift
  • Docker without any https/SSL validation?
  • Docker quickstart terminal not opening
  • Docker GCE, Layer already being pulled by another client. Waiting
  • Phalcon doesnt work properly on nginx
  • Sporadic Robolectric test failures when running inside Docker container
  • I find the inconsistent variable handling very frustrating; How am I supposed to specify this directory for use?

  • Can not pull/push images after update docker to 1.12
  • Odoo development on Docker
  • Accessing Docker container other than ssh
  • Loading PostgreSQL Database Backup Into Docker/Initial Docker Data
  • Docker-compose failed running a jar that read configuration from a file
  • maven-docker-plugin: how to get container ip address
  • One Solution collect form web for “How to use env var in WORKDIR stanza?”

    See Github issue here: The issue suggests this has now been fixed. Are you using the latest version?

    You can also override the WORKDIR in the Dockerfile when calling docker run:

    docker run -w=/root/mypackage-0.13
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.