- /rancher/v2.x/en/installation/single-node-install/
For development and testing environments, we recommend installing Rancher by running a single Docker container. In this installation scenario, you'll install Docker on a single Linux host, and then deploy Rancher on your host using a single Docker container.
Want to use an external load balancer? See Single Node Install with an External Load Balancer instead.
1. Provision Linux Host
Provision a single Linux host according to our Requirements to launch your {{< product >}} Server.
2. Choose an SSL Option and Install Rancher
For security purposes, SSL (Secure Sockets Layer) is required when using Rancher. SSL secures all Rancher network communication, like when you login or interact with a cluster.
Do you want to...
- Use a proxy? See HTTP Proxy Configuration
- Configure custom CA root certificate to access your services? See Custom CA root certificate
- Complete an Air Gap Installation? See Air Gap: Single Node Install
- Record all transactions with the Rancher API? See API Auditing
Choose from the following options:
{{% accordion id="option-a" label="Option A-Default Self-Signed Certificate" %}}
If you are installing Rancher in a development or testing environment where identity verification isn't a concern, install Rancher using the self-signed certificate that it generates. This installation option omits the hassle of generating a certificate yourself.
Log into your Linux host, and then run the minimum installation command below.
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
rancher/rancher:latest
{{% /accordion %}} {{% accordion id="option-b" label="Option B-Bring Your Own Certificate: Self-Signed" %}} In development or testing environments where your team will access your Rancher server, create a self-signed certificate for use with your install so that your team can verify they're connecting to your instance of Rancher.
Prerequisites: Create a self-signed certificate using OpenSSL or another method of your choice.
- The certificate files must be in PEM format.
- In your certificate file, include all intermediate certificates in the chain. Order your certificates with your certificate first, followed by the intermediates. For an example, see SSL FAQ / Troubleshooting.
After creating your certificate, run the Docker command below to install Rancher. Use the -v flag and provide the path to your certificates to mount them in your container.
- Replace
<CERT_DIRECTORY>with the directory path to your certificate file. - Replace
<FULL_CHAIN.pem>,<PRIVATE_KEY.pem>, and<CA_CERTS>with your certificate names.
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
-v /<CERT_DIRECTORY>/<FULL_CHAIN.pem>:/etc/rancher/ssl/cert.pem \
-v /<CERT_DIRECTORY>/<PRIVATE_KEY.pem>:/etc/rancher/ssl/key.pem \
-v /<CERT_DIRECTORY>/<CA_CERTS.pem>:/etc/rancher/ssl/cacerts.pem \
rancher/rancher:latest
{{% /accordion %}} {{% accordion id="option-c" label="Option C-Bring Your Own Certificate: Signed by Recognized CA" %}}
In production environments where you're exposing an app publicly, use a certificate signed by a recognized CA so that your user base doesn't encounter security warnings.
Prerequisite: The certificate files must be in PEM format.
After obtaining your certificate, run the Docker command below.
-
Use the
-vflag and provide the path to your certificates to mount them in your container. Because your certificate is signed by a recognized CA, mounting an additional CA certificate file is unnecessary.- Replace
<CERT_DIRECTORY>with the directory path to your certificate file. - Replace
<FULL_CHAIN.pem>and<PRIVATE_KEY.pem>with your certificate names.
- Replace
-
Use the
--no-cacertsas argument to the container to disable the default CA certificate generated by Rancher.
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
-v /<CERT_DIRECTORY>/<FULL_CHAIN.pem>:/etc/rancher/ssl/cert.pem \
-v /<CERT_DIRECTORY>/<PRIVATE_KEY.pem>:/etc/rancher/ssl/key.pem \
rancher/rancher:latest --no-cacerts
{{% /accordion %}} {{% accordion id="option-d" label="Option D-Let's Encrypt Certificate" %}}
For production environments, you also have the options of using Let's Encrypt certificates. Let's Encrypt uses an http-01 challenge to verify that you have control over your domain. You can confirm that you control the domain by pointing the hostname that you want to use for Rancher access (for example, rancher.mydomain.com) to the IP of the machine it is running on. You can bind the hostname to the IP address by creating an A record in DNS.
Prerequisites:
- Let's Encrypt is an Internet service. Therefore, this option cannot be used in an internal/air gapped network.
- Create a record in your DNS that binds your Linux host IP address to the hostname that you want to use for Rancher access (
rancher.mydomain.comfor example).- Open port
TCP/80on your Linux host. The Let's Encrypt http-01 challenge can come from any source IP address, so portTCP/80must be open to all IP addresses.
After you fulfill the prerequisites, you can install Rancher using a Let's Encrypt certificate by running the following command. Replace <YOUR.DNS.NAME> with your your domain.
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
rancher/rancher:latest \
--acme-domain <YOUR.DNS.NAME>
Remember: Let's Encrypt provides rate limits for requesting new certificates. Therefore, limit how often you create or destroy the container. For more information, see Let's Encrypt documentation on rate limits. {{% /accordion %}}
What's Next?
- Recommended: Review Single Node Backup and Restoration. Although you don't have any data you need to back up right now, we recommend creating backups after regular Rancher use.
- Create a Kubernetes cluster: Provisioning Kubernetes Clusters.
FAQ and Troubleshooting
{{< ssl_faq_single >}}
Advanced Options
Enable API Audit Log
The API Audit Log records all the user and system transactions made through Rancher server.
The API Audit Log writes to /var/log/auditlog inside the rancher container by default. Share that directory as a volume and set your AUDIT_LEVEL to enable the log.
See API Audit Log for more information and options.
docker run -d --restart=unless-stopped \
-p 80:80 -p 443:443 \
-v /var/log/rancher/auditlog:/var/log/auditlog \
-e AUDIT_LEVEL=1 \
rancher/rancher:latest
Air Gap
If you are visiting this page to complete an air gap installation, you must pre-pend your private registry URL to the server tag when running the installation command in the option that you choose. Add <REGISTRY.DOMAIN.COM:PORT> with your private registry URL in front of rancher/rancher:latest.
Example:
<REGISTRY.DOMAIN.COM:PORT>/rancher/rancher:latest
Persistent Data
{{< persistentdata >}}
Running rancher/rancher and rancher/rancher-agent on the Same Node
In the situation where you want to use a single node to run Rancher and to be able to add the same node to a cluster, you have to adjust the host ports mapped for the rancher/rancher container.
If a node is added to a cluster, it deploys the nginx ingress controller which will use port 80 and 443. This will conflict with the default ports we advice to expose for the rancher/rancher container.
Please note that this setup is not recommended for production use, but can be convenient for development/demo purposes.
To change the host ports mapping, replace the following part -p 80:80 -p 443:443 with -p 8080:80 -p 8443:443:
docker run -d --restart=unless-stopped \
-p 8080:80 -p 8443:443 \
rancher/rancher:latest