title: LD_PRELOAD in docker
body: <p>When I run docker as following:</p>
  
  <pre><code>docker run -it -e LD_PRELOAD=/bin/xyz.so bash env
  </code></pre>
  
  <p>It runs as expected, and the output is:</p>
  
  <pre><code>HOSTNAME=2116ac3bae11
  _BASH_VERSION=4.4
  _BASH_LATEST_PATCH=23
  PWD=/
  HOME=/root
  _BASH_GPG_KEY=7C0135FB088AAF6C66C650B9BB5869F064EA74AB
  TERM=xterm
  SHLVL=0
  PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  _BASH_PATCH_LEVEL=18
  LD_PRELOAD=/bin/xyz.so
  </code></pre>
  
  <p>However, when I run the same command but with another image, such as ubuntu or centos:</p>
  
  <pre><code>docker run -it -e LD_PRELOAD=/bin/xyz.so ubuntu env
  docker run -it -e LD_PRELOAD=/bin/xyz.so centos:7 env
  </code></pre>
  
  <p>The LD_PRELOAD variable disappearing from the output:</p>
  
  <pre><code>PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  HOSTNAME=00b161980ef6
  TERM=xterm
  HOME=/root
  </code></pre>
  
  <p>Can anyone explain what is the difference between the commands?
  How can I run centos image with LD_PRELOAD?</p>
  
  <p>It seems to be some docker security mechanism which clearing the LD_PRELOAD from the environment variables. But why only in the last commands and not in the first one?</p>
  
  <p>Docker version 17.12.1-ce, build 7390fc6</p>