我想运行一个容器并将主机IP(容器可见)作为环境变量传递给我的容器,我该怎么做?
这是它应该的样子:
docker run -it --rm -e HOST_IP=`script which will give me the host IP visible by the future running container` myimage
答案 0 :(得分:1)
docker run -it --rm -e HOST_IP=`/sbin/ip route | awk '/docker/ {print $9 }'` myimage