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.

  • How to use Nomad with Nvidia Docker?
  • Number of threads used by Go runtime
  • Amazon Beanstalk - nginx configuration
  • Docker UCP Content Trust not work, notary
  • How to install features in WSO2 using a shell script
  • Jupyterhub/singleuser shared volume
  • 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?

  • SaltStack doesn't start docker container
  • How to continue using docker container after startup application exit?
  • Portainer not able to list the running containers on Rancher OS
  • How would you go about dockerfile and rpm scripting?
  • How can I terminate a Docker instance from within itself?
  • Is there a way to download docker hub images whitout “docker pull” for a machine with out Internet access?
  • 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 :

    ARG MY_ARG
    
    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.