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 apps which aren't running?
  • Docker container mongod error when starting via ssh
  • Mesos/Marathon on EC2 agents hostnames not accessible
  • How to install docker's btrfs volume plugin?
  • Connection refused on spring-client with docker and gradle
  • docker pull/push not working with insecure registry
  • I find the inconsistent variable handling very frustrating; How am I supposed to specify this directory for use?

  • How can I set an overlay network within docker compose
  • Where should I install SQL Management Server instances on my development machine?
  • Does Kubernetes evenly distribute across an ec2 cluster?
  • Environment variables for docker-compose inside of Jenkins
  • What's Better for Many Containers: a Large Custom Base Image or Several Small Custom Images?
  • What is the correct way of using a custom Dragonfly storage backend in Refinery?
  • 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.