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 image tag is not working
  • Like “make” for Docker
  • Creating a CI pipeline for .net containerized applications
  • How do I undo the command $ eval “$(docker-machine env blog)”
  • Docker volumes doesn't exist for data container in 1.9.1
  • How to save application state in Marathon?
  • 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?

  • Build container with docker-compose, but run /etc/bash with -it option later?
  • How to connect to the external server from docker container?
  • Passing ES_JAVA_OPTS variable with spaces when using docker compose
  • Random container names when building from the same docker-compose file
  • building docker image from dockerfile
  • How can I run `gcloud preview app setup-managed-vms` without this error?
  • 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.