# How to add env param?

**URL:** <https://forums.suse.com/t/how-to-add-env-param/6586>\
**Category:** Rancher 1.x\
**Created:** [June 9, 2017, 2:52am UTC](https://forums.suse.com/t/how-to-add-env-param/6586 "2017-06-09T02:52:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![lifubang](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/lifubang/32/2521_2.png) [@lifubang](https://forums.suse.com/u/lifubang)\
**Post date:** [June 9, 2017, 2:52am UTC](https://forums.suse.com/t/how-to-add-env-param/6586/1 "2017-06-09T02:52:26Z")

</div>

Before rancher, I create docker container with the script:  
docker run --shm-size=1G --cap-add NET\_ADMIN --privileged=true -v /home/oj/data:/home/oj/data -v /home/soft:/home/soft -v /home/oj/log:/home/oj/log -v /home/oj/etc:/home/oj/etc -p 2222:22 --restart=always --name=oj2 **–env hostip** =`ifconfig eth0 | awk ‘/inet addr:/{print $2}’ | awk -F: ‘{print $2}’` -it --entrypoint=/home/soft/ojdaemon [docker.acmcoder.com/oj:latest](http://docker.acmcoder.com/oj:latest) /home/oj 1

In the container, I want to use env param hostip, and the value of it is the host eth0’s ip address.

When I create a service in rancher, I add the env param like this: hostip=`ifconfig eth0 | awk ‘/inet addr:/{print $2}’ | awk -F: ‘{print $2}’`  
In the container, when I echo $hostip, It displays `ifconfig eth0 | awk ‘/inet addr:/{print $2}’ | awk -F: ‘{print $2}’`, not the host eth0’s ip address.

How to pass a `shell script` result to the env value?

---

<div class="post-metadata">

**Author:** ![StrongMonkey](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/strongmonkey/32/2476_2.png) [@StrongMonkey](https://forums.suse.com/u/StrongMonkey)\
**Post date:** [June 9, 2017, 5:47pm UTC](https://forums.suse.com/t/how-to-add-env-param/6586/2 "2017-06-09T17:47:28Z")

</div>

you can do that in entrypoint script. Evaluate your ip address and set it as an environment variable in the script.

---

<div class="post-metadata">

**Author:** ![imorti](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/imorti/32/2332_2.png) [@imorti](https://forums.suse.com/u/imorti)\
**Post date:** [June 11, 2017, 9:19pm UTC](https://forums.suse.com/t/how-to-add-env-param/6586/3 "2017-06-11T21:19:35Z")

</div>

what OS are you using?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [June 12, 2017, 10:05pm UTC](https://forums.suse.com/t/how-to-add-env-param/6586/4 "2017-06-12T22:05:25Z")

</div>

You can get the IP of the host you’re running on from metadata, but you cannot do something like what you’re showing. That only works because you’re in a shell on the target host and letting it interpret that. The Rancher (or Docker Remote) API does not shell-interpret values.

---

<div class="post-metadata">

**Author:** ![lifubang](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/lifubang/32/2521_2.png) [@lifubang](https://forums.suse.com/u/lifubang)\
**Post date:** [June 13, 2017, 3:19am UTC](https://forums.suse.com/t/how-to-add-env-param/6586/5 "2017-06-13T03:19:15Z")

</div>

my os version is Ubuntu 14.04

---

<div class="post-metadata">

**Author:** ![lifubang](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/lifubang/32/2521_2.png) [@lifubang](https://forums.suse.com/u/lifubang)\
**Post date:** [June 13, 2017, 3:21am UTC](https://forums.suse.com/t/how-to-add-env-param/6586/6 "2017-06-13T03:21:00Z")

</div>

I want to get the host computer’s ip address, but not the container’s ip address. How to get the host machine’s ip address in entrypoint script.

---

<div class="post-metadata">

**Author:** ![lifubang](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/lifubang/32/2521_2.png) [@lifubang](https://forums.suse.com/u/lifubang)\
**Post date:** [June 13, 2017, 3:42am UTC](https://forums.suse.com/t/how-to-add-env-param/6586/7 "2017-06-13T03:42:53Z")

</div>

For example, I have 100 machines in the cloud, and I can get the host list of these machines as follows:  
Internet IP Address, Intranet IP Address, Instance ID/Name  
47.93.81.28, 10.30.136.49, oj1  
47.93.81.29, 10.30.136.50, oj2  
…

When I run one container on each machines, the daemon process on each container tell the db server his unique id. So I can monitor each daemon process’s running data. But how to know who is the host of daemon process from a unique id? When daemon process use ip address as his unique id, it just like this: 10.42.88.53, 10.42.88.54. It’s the container’s ip address, but not the host’s ip address, so I can’t map to the host list provided by cloud platform.

Can you give me a solution? Thanks.
