When I run docker as following:
docker run -it -e LD_PRELOAD=/bin/xyz.so bash env
It runs as expected, and the output is:
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
However, when I run the same command but with another image, such as ubuntu or centos:
docker run -it -e LD_PRELOAD=/bin/xyz.so ubuntu env
docker run -it -e LD_PRELOAD=/bin/xyz.so centos:7 env
The LD_PRELOAD variable disappearing from the output:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=00b161980ef6
TERM=xterm
HOME=/root
Can anyone explain what is the difference between the commands? How can I run centos image with LD_PRELOAD?
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?
Docker version 17.12.1-ce, build 7390fc6