rancher: Failed to register the host with Rancher

Rancher Version: v1.1.3

Docker Version: v1.1.3

OS and where are the hosts located? (cloud, bare metal, etc): Mac OSX 10.11.6 Local machine

Setup Details: (single node rancher vs. HA rancher, internal DB vs. external DB) Single node rancher

Environment Type: (Cattle/Kubernetes/Swarm/Mesos) None. Just docker.

Steps to Reproduce:

  1. $ git clone https://github.com/rancher/rancher.git
  2. $ cd rancher
  3. $ docker run -d --restart=always -p 8080:8080 rancher/server
  4. Go to localhost:8080
  5. On “Adding your first host”, Click on Add Host
  6. On “Custom” tab, copy step 5: 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://localhost:8080/v1/projects/1a5/scripts/0A8F9C5022B9E31A1B54:1473274800000:HP1iZa94EwdJMFCNYM5Erlw9ig
  7. Run it.

Results:

$ 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://localhost:8080/v1/scripts/313757F94E51711D2ACF:1473271200000:IItuw8awr69IebBZEIZr0wjeM8
Password:
Unable to find image 'rancher/agent:v1.0.2' locally
v1.0.2: Pulling from rancher/agent
5a132a7e7af1: Already exists
fd2731e4c50c: Already exists
28a2f68d1120: Already exists
a3ed95caeb02: Already exists
7fa4fac65171: Pull complete
33de63de5fdb: Pull complete
d00b3b942272: Pull complete
Digest: sha256:b0b532d1e891534779d0eb1a01a5717ebfff9ac024db4412ead87d834ba92544
Status: Downloaded newer image for rancher/agent:v1.0.2
963c83d344e5fb28fd826860e15bcf7d34674ec5815b432cb6037984cfbb4c6a
docker: Error response from daemon: Mounts denied:
The path /var/lib/rancher
is not shared from OS X and is not known to Docker.
You can configure shared paths from Docker -> Preferences... -> File Sharing.
See https://docs.docker.com/docker-for-mac/osxfs/#namespaces for more info.
..

Expected: It should add a new host to Rancher

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 7
  • Comments: 22 (2 by maintainers)

Most upvoted comments

  1. Goto your Rancher env, Hosts | Add Host, select Custom
  2. Copy the command, replace the /var/lib/rancher mount to -v /private/var/lib/rancher:/var/lib/rancher and sudo mkdir -p /var/lib/rancher
  3. Add /private/var/lib to Docker -> Preferences… -> File Sharing
  4. Run the custom command in terminal to connect the agent

Should do the trick!

@robertcsakany Here are two things I did.

  1. Use actual public IP address rather than localhost. Read Add Hosts why this should be done.
  2. In the command you have to run, change from -v /var/lib/rancher:/var/lib/rancher to -v /repository_where_rancher_is_stored:/var/lib/rancher

@serv are u saying if i want to run a rancher agent on physical machine or virtual machine ,i need to clone the source code and point to this directory in the “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://localhost:8080/v1/scripts/41378FF43526C55B72AD:1474819200000:qyh6fdvTlecx9ALCCU2M0FZVnyo

@wanghaisheng Rancher source code that you cloned from this repo

@serv what do you mean by repository_where_rancher_is_stored ?rancher source code or mysql data ?