Installing Rancher under Docker For Mac
Original text: How to install Rancher on OS X
Rancher is a Docker orchestration solution. Its advantage is that it can do container orchestration, network, storage and load balancing. It also supports cloud servers (such as Amazon EC2/Azure/DigitalOcean) and is compatible with other solutions such as Docker Swarm/Mesos/Kubernetes. Since it has not been released, it has received continuous attention. It has a problem of its own RancherOS It is also a big threat to CoreOS.
Because it provides a very optimized background management interface and REST API, it is very convenient in daily development and use. If you have to say something bad, it may be that it has a small requirement for memory: the minimum memory is 1GB. Therefore, if you want to put children's shoes on your VPS, you need to evaluate them.
Mac installation
This one, too Docker for Mac Finally get rid of the torture of docker machine. You don't have to rely on VirtualBox, load machine variables and find the IP of virtual machine every time. The mapped ports are accessed through localhost.
The installation of Rancher through Docker is very simple. It is divided into server and client. This tutorial Single Node To explain, do not consider Multi Node.
There has never been a good solution on the Internet. I see many foreign solutions Solution It's also troublesome, mainly because Docker for mac uses xhyve as a lightweight virtualization scheme, while Ranger has no problem installing the server side. When adding a host, it needs to connect to the server side through HTTP and fails. Now I'll take you to disassemble it with the simplest scheme. No assistance from any third party is required.
Server
If the network speed is too slow to connect to the docker hub, you can consider using proxy settings or domestic image services. I share one here https://docker.mirrors.ustc.edu.cn , can be added in docker - > preferences... - > Advanced - > registry mirror.
$ docker run -d --name rancher-server --restart=always -p 8181:8080 rancher/server $ docker logs -f rancher-server ...... time="2016-11-24T03:29:30Z" level=info msg="Updating machine jsons for [packet packet amazonec2 azure digitalocean]" time="2016-11-24T03:29:31Z" level=info msg="Creating schema machine, roles [service]" id=1ds17 time="2016-11-24T03:29:32Z" level=info msg="Creating schema machine, roles [project member owner]" id=1ds18 time="2016-11-24T03:29:32Z" level=info msg="Creating schema machine, roles [admin user readAdmin]" id=1ds19 time="2016-11-24T03:29:32Z" level=info msg="Creating schema machine, roles [readonly]" id=1ds20 time="2016-11-24T03:29:41Z" level=info msg=Event eventId=dad01e6e-672c-47bf-8e64-342690a91780 name="machinedriver.activate;handler=goMachineService-machine" resourceId=1md1
See the log similar to the above, indicating that the service has been initialized and accessed through the browser http://localhost:8181 You can see the background management interface.
client
Don't worry about continuing the page operation first. Go back to the terminal and execute the following command to obtain the IP address of the Ranger server container for backup
$ docker inspect --format '{{ .NetworkSettings.IPAddress }}' rancher-server 172.17.0.2
Next, in the above steps, you can see the Add Host button on the open page and click "Something else:" for the pop-up "Host Registration URL", fill in the above IP and port number in the following input box http://172.17.0.2:8080 And save.
After that, we will give you an option of client (deployment host). Since we only add the local machine as the deployment host, we choose Custom here. Without any other settings, slide directly to the bottom to find an area where the docker command is executed:
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://172.17.0.2:8080/v1/scripts/C963E2BB46185F46E3A1:1479956400000:aNMAicxpI5BtVAzbLAZOp6rw --name rancher-agent
You will find that the execution may report an error:
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.
At present, it may be a Docker Bug, because / var / lib / Ranger is attached to the / private file share that has been added by default, but it still reports an error. If you add it in the File Sharing set by Docker, it will not let you add it. Therefore, we need to make a small modification:
docker run -d --privileged -v /var/run/docker.sock:/var/run/docker.sock -v ${HOME}/docker/rancher:/var/lib/rancher rancher/agent:v1.0.2 http://172.17.0.2:8080/v1/scripts/C963E2BB46185F46E3A1:1479956400000:aNMAicxpI5BtVAzbLAZOp6rw --name rancher-agent
Finally, after clicking Close on the page, you will jump to the Host list, and you will be pleasantly surprised to find that the addition is successful!