Shell variables in dockerfile missing in docker image labels

I have a Dockerfile containing some text that looks like ‘$MYVARIABLE’ passed in as labels (these strings are used for custom tooling).

I’m noticing that once this Dockerfile is successfully built that a docker inspect of the resultant image shows blank space where these ‘$MYVARIABLE’ style strings are in the Dockerfile. I just want ‘$MYVARIABLE’ passed as a literal string I don’t want it treated as a variable at all.

  • Docker compose apache not working
  • Unable to activate chef-provisioning-docker-0.6 because chef-provisioning-1.1.1 conflicts with chef-provisioning (~> 0.9)
  • Docker Compose: Detect whether image needs to be re-built
  • docker unrecognised service when i run this command sudo service docker stop
  • how to pass a --login into docker build
  • how force deleting docker image affects existing containers using it
  • My first guess was that my shell is trying to expand these as if they were regular variables even though I’m not using Dockerfile ARG or ENV syntax. I concluded this was not the case. So my question is where are these strings going?

  • Winston Not Logging
  • How to merge two running Docker Containers?
  • how to connect a docker container to network
  • Docker - Run Jetty on HTTPS
  • Customize docker-java response to remove some logger like stream
  • Running Maven inside a Cloud9 Docker container
  • One Solution collect form web for “Shell variables in dockerfile missing in docker image labels”

    You would need to declare the passed var as an ARG in the dockerfile.
    That is if you want to use the var MY_ARG as Label , you would have to declare it in the following manner :

    LABEL "My Arg"=$MY_ARG

    If you are already doing that , maybe the issue is with how those variables are initialized/passed.Maybe some code will help.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.