# Add host and Rancher agent

**URL:** <https://forums.suse.com/t/add-host-and-rancher-agent/4288>\
**Category:** Rancher 1.x\
**Created:** [October 12, 2016, 7:01pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288 "2016-10-12T19:01:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![markwebwyatt](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@markwebwyatt](https://forums.suse.com/u/markwebwyatt)\
**Post date:** [October 12, 2016, 7:01pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/1 "2016-10-12T19:01:39Z")

</div>

I am new to Rancher. I had it working great on a Virtualbox machine running Ubuntu 14.04 with Docker. I accidently filled the harddrive and the virtual machnie stopped working. So I started over with a new virutal machine with Ubuntu 14.04 and Docker.

I ran:  
sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server  
and Rancher works fine at this address: [http://127.0.0.1:8080](http://127.0.0.1:8080)

When I try to run the agent command, it does not work, and I cannot add a host.

I have spent a whole day trying all kinds of ip addresses and variations to the command. I noticed that it is a different command on your site at:  
[http://docs.rancher.com/rancher/v1.2/en/quick-start-guide/](http://docs.rancher.com/rancher/v1.2/en/quick-start-guide/)

than the command that shows up in Rancher. The Rancher command puts quotes around the ip address and also does uses the ip 127.0.0.1:8080 in the second location of the command.

Anty help you can give for me to get the agent running and to add a host would be much appreciated

here is my ifconfig info:

docker0 Link encap:Ethernet HWaddr 02:42:9d:b6:66:60  
inet addr:172.17.42.1 Bcast:0.0.0.0 Mask:255.255.0.0  
inet6 addr: fe80::42:9dff:feb6:6660/64 Scope:Link  
UP BROADCAST MULTICAST MTU:1500 Metric:1  
RX packets:6822 errors:0 dropped:0 overruns:0 frame:0  
TX packets:6815 errors:0 dropped:0 overruns:0 carrier:0  
collisions:0 txqueuelen:0  
RX bytes:1501909 (1.5 MB) TX bytes:4306845 (4.3 MB)

eth0 Link encap:Ethernet HWaddr 08:00:27:d4:b1:41  
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0  
inet6 addr: fe80::a00:27ff:fed4:b141/64 Scope:Link  
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1  
RX packets:1020745 errors:0 dropped:0 overruns:0 frame:0  
TX packets:478865 errors:0 dropped:0 overruns:0 carrier:0  
collisions:0 txqueuelen:1000  
RX bytes:839220993 (839.2 MB) TX bytes:31225201 (31.2 MB)

lo Link encap:Local Loopback  
inet addr:127.0.0.1 Mask:255.0.0.0  
inet6 addr: ::1/128 Scope:Host  
UP LOOPBACK RUNNING MTU:65536 Metric:1  
RX packets:10739 errors:0 dropped:0 overruns:0 frame:0  
TX packets:10739 errors:0 dropped:0 overruns:0 carrier:0  
collisions:0 txqueuelen:0  
RX bytes:2093261 (2.0 MB) TX bytes:2093261 (2.0 MB)

---

<div class="post-metadata">

**Author:** ![sjiveson](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sjiveson/32/966_2.png) [@sjiveson](https://forums.suse.com/u/sjiveson)\
**Post date:** [October 13, 2016, 11:34am UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/2 "2016-10-13T11:34:00Z")

</div>

Are you trying to run the agent on the same host/VM as the server container?

---

<div class="post-metadata">

**Author:** ![markwebwyatt](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@markwebwyatt](https://forums.suse.com/u/markwebwyatt)\
**Post date:** [October 13, 2016, 12:20pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/3 "2016-10-13T12:20:07Z")

</div>

Yes, I am running the agent and host on same VM as the server containers

---

<div class="post-metadata">

**Author:** ![johnrengelman](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/johnrengelman/32/134_2.png) [@johnrengelman](https://forums.suse.com/u/johnrengelman)\
**Post date:** [October 13, 2016, 9:17pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/4 "2016-10-13T21:17:33Z")

</div>

I think you need to pass the environment variable CATTLE\_AGENT\_IP to your rancher agent container in this case. The IP needs to be your machine’s IP, not the docker bridge or anything like that.

---

<div class="post-metadata">

**Author:** ![markwebwyatt](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@markwebwyatt](https://forums.suse.com/u/markwebwyatt)\
**Post date:** [October 14, 2016, 12:09pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/5 "2016-10-14T12:09:59Z")

</div>

It is really strange. The first time I set up Rancher last week it was very easy. I am not sure what might have changed.

Here is the code generated by Rancher:

sudo docker run -e CATTLE\_AGENT\_IP=“10.0.2.15” -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 [http://127.0.0.1:8080/v1/scripts/569C2D3B05B548B9B535:1476446400000:pdGUrq9sSMPea5yQdf8jPGorR9s](http://127.0.0.1:8080/v1/scripts/569C2D3B05B548B9B535:1476446400000:pdGUrq9sSMPea5yQdf8jPGorR9s)

10.0.2.15 is the IP of my machine

I have tried several variations of it with many different IP addresses.

I also tried this:

docker run -e CATTLE\_AGENT\_IP=10.0.2.15 -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 [http://10.0.2.15:8088/v1/scripts/569C2D3B05B548B9B535:1476446400000:pdGUrq9sSMPea5yQdf8jPGorR9s](http://10.0.2.15:8088/v1/scripts/569C2D3B05B548B9B535:1476446400000:pdGUrq9sSMPea5yQdf8jPGorR9s)

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [October 14, 2016, 2:36pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/6 "2016-10-14T14:36:35Z")

</div>

@markwebwyatt Just to note, it looks like your last attempt had `8088` instead of `8080` as the port exposed for Rancher. But it should be `8080`.

Have you looked at the FAQs?

[http://docs.rancher.com/rancher/v1.2/en/faqs/agents/](http://docs.rancher.com/rancher/v1.2/en/faqs/agents/)

---

<div class="post-metadata">

**Author:** ![markwebwyatt](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@markwebwyatt](https://forums.suse.com/u/markwebwyatt)\
**Post date:** [October 14, 2016, 2:52pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/7 "2016-10-14T14:52:38Z")

</div>

I finally got my original VM to run and Rancher works fine. It is version 1.1.3 and it is running on eth0 IP which is 10.0.2.15

on my new VM I am running Rancher Server Version 1.1.4  
When I run this command:  
docker run -d --restart=always -p 8080:8080 rancher/server  
It runs on lo IP address by default whcih is 127.0.0.1

How do I run rancher server on my eth0 IP instead of lo ip?

---

<div class="post-metadata">

**Author:** ![markwebwyatt](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@markwebwyatt](https://forums.suse.com/u/markwebwyatt)\
**Post date:** [October 18, 2016, 12:53pm UTC](https://forums.suse.com/t/add-host-and-rancher-agent/4288/8 "2016-10-18T12:53:35Z")

</div>

I solved the issue. I installed Rancher Server Version 1.1.3 and it worked the first time. I was able to add a host by using the code:

sudo docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.0.2 [http://10.0.2.15:8080/v1/scripts/D5B3A2AC102E979E742B:1476792000000:cnCZeKqpHl4KS2ZXiYwimTys4Q](http://10.0.2.15:8080/v1/scripts/D5B3A2AC102E979E742B:1476792000000:cnCZeKqpHl4KS2ZXiYwimTys4Q)

Rancher Server Version 1.1.4 does something different than V1.1.3.  
V1.1.4 uses a different IP on my machine. And also will not allow me to add a host.
