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.

  • Error Docker deployment in Amazon Elastic Beanstalk - Docker container quit unexpectedly
  • Docker: How to save running instance?
  • How to obtain Docker image ID from API after building?
  • Fetching git behind proxy in docker container
  • Docker container's /proc/<pid>/stat not updating CPU stats
  • Composer doesn't see GD extension
  • 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?

  • How to create docker base image from Amazon Linux AMI
  • OpenERP-docker container won't start
  • How to speed up CI build times when using docker?
  • Not able to access tomcat application on Docker VM with host(windows) IP while using docker toolbox
  • Passing Different Arguments When Running Docker Image Multiple Times
  • where are apps installed using apt-get within Dockerfile?
  • 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.