title: How to use docker image internal environment variable in Jenkinsfile?
body: <p>I'm currently facing the problem that Jenkins tries to access/replace the env variable in a <code>sh</code> script from outside, while the property is defined inside the container:</p>
  <pre><code>    stage('Run phpunit') {
        agent {
          docker { image 'php:7.2-alpine' }
        }
        steps {
          sh &quot;&quot;&quot;
            apk add --no-cache ${PHPIZE_DEPS}
            pecl install xdebug
            docker-php-ext-enable xdebug
            php vendor/bin/phpunit --colors=never --log-junit build/junit.xml --coverage-clover build/clover.xml
          &quot;&quot;&quot;
        }
      }
  </code></pre>
  <p>Jenkins fails this step with the message:</p>
  <pre><code>groovy.lang.MissingPropertyException: No such property: PHPIZE_DEPS for class: groovy.lang.Binding
  at groovy.lang.Binding.getVariable(Binding.java:63)
  at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:242)
  at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
  at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
  at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
  </code></pre>