Rancher Server v1

  • Rancher provides some very intriguing features:
    • A docker image repository
    • The ability to add target hosts running the Rancher agent.
    • Secrets storage
  • The v1 Rancher server is effectively an all-in-one alternative to Kubernetes, ECS, EKS, et. al.,

  • Rancher is very good as an on-prem datacenter solution, particularly for development.
  • It is very easy to take a series of on-prem physical servers and provide the Rancher interface to developers or an entry-level ops team.
  • Where Rancher falls short is in cloud deployments.
    • The method of adding target hosts can be automated using the API, but there is almost as much heavy lifting to make Rancher work as you would invest with another product like Kubernetes, ECS, or EKS.
    • Rancher doesn’t like it if the resolv.conf is set to lookup against localhost. It’s rare that localhost would be used as a DNS server, but little quirks like that will cause the Rancher agent to immediately fail.
  • In the end Rancher will feel like using VMware VCenter for Docker. And maybe that’s ok.
  • You have to add hosts manually to Rancher, and the experience is a bit unpredictable.
  • However, the GUI for provisioning docker containers means that even the most inexperienced person can instantly start working with docker and all the myriad of parameters.
  • Rancher is a great solution for a simple setup, but doesn’t make much sense outside of that environment.
  • Rancher feels like a product trying desperately to get some traction in the container ecosystem rather than spend the time to make a polished solution.

Rancher Server

The Rancher Server is a central node which all Rancher Agents connect back to.

Start the Rancher Server

docker pull rancher/server:latest

docker run -d \
  -p 8080:8080 \
  --name rancher-server \

Visit the Rancher console

  • Once the Rancher server is up and running, connect to the console

Rancher Agent

  • Install the Rancher Agent on any host where Docker agents will be run.
  • The agent host must be Linux-based and running the Docker daemon.

Agent credentials

  • The agent credentials are acquired by going to the rancher server console and adding a host.

Start the Rancher Agent

docker pull rancher/agent:latest

export RANCHER_AGENT_CREDS2="1514678400000"

## Rancher agent will not start if nameserver is localhost
echo "nameserver" > /etc/resolv.conf

docker run -d --name rancher-agent \
  --rm --privileged \
  --dns= \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v /var/lib/rancher:/var/lib/rancher \
  rancher/agent:latest \

Host stuck in the “Reconnecting” state

  • Remove the rancher agent containers.
docker ps -a | awk '{print "docker stop "$1; print "docker rm "$1; }' | sh
  • Use the command that Rancher gives to start a custom host
docker stop rancher-agent
docker rm rancher-agent

docker run --rm --network=host --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.11

Deploy a container using the Rancher server

Image, ports, and environment variables


Network type

  • Pay close attention to the network type.
  • If you just want to use Rancher to start a container in the “normal” way ensure that you set the network type to bridged.

categories: rancher | rancher1 | docker |