Add host and Rancher agent

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

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/

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)

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

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

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.

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

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

@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/

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?

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

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.