[HowTo] FreeNAS 11.1 + RancherOS + Docker + RancherUI + PLEX

Yusuf Limalia

Patron
Joined
Apr 5, 2016
Messages
234
Alllllll right. I have finally freed myself from the bindings of Corral and I'm back on the train. Corral's method of handling Docker was just amazing. It hid much of the complexity and let an idiot like me get up and running with minimal knowledge of Docker. After some wrestling with RancherOS I much prefer 11.1's implementation. While it is slightly more complex, it is more customizable, and is much more scalable.
This is what you get if you mix a Shark with a Bull and a Whale. Hilarity Ensues.

First some caveats:
1) This is how I set mine up. There is always a better way of doing it, I'm all ears! I'm sure there will be people with complicated feelings below.
2.1) **EDIT** - Updated the mount storage part so that mounted volumes will persist even after reboot
2.2) **EDIT** - Updated the Networking section and changed from bridge to host
3) This guide is a good way of understanding how it all CAN fit together.

Diagram:
upload_2017-12-20_14-44-11.png


  • My FreeNAS box has 2 x NICs, the one associated with my virtualization is em1 (10.1.2.252)
  • RancherOS sits on em1
  • Rancher/Server is an interface for managing a docker cluster! So many large scale companies actually use it
  • Docker sits inside RancherOS and is setup with a host network
  • UPDATE - The official PLEX documentation recommends the host network, so I've changed to that. The host networking uses the IP address of the host running docker such that a container's networking appears to be the host rather than separate.
  • If you must use bridge - Any container that sits inside docker and if it's on the bridge network is accessed via an internal NAT by its port. It can work but the setup is slightly more complex.
1. Setup RancherOS / DockerVM
Follow the official documentation here:
http://doc.freenas.org/11/vms.html#docker-rancher-vm

NB: If you have 2 x NICs and want to set a static IP for your RancherOS
Before running the docker command:
sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server
Set your RancherOS static IP by:

Check what your interface is (eth0 is default) by running:
ifconfig

When you get your interface run the following commands:
sudo ros config set rancher.network.interfaces.eth0.address 10.1.2.252/24
sudo ros config set rancher.network.interfaces.eth0.gateway 10.1.2.1
sudo ros config set rancher.network.interfaces.eth0.mtu 1500
sudo ros config set rancher.network.interfaces.eth0.dhcp false


Continue with the guide and access your UI by navigating to IP:8080

upload_2017-12-20_14-51-4.png


2. Security
Many ways of limiting access. The easiest is Local Authentication
Head over to ADMIN > Access Control > Add Account
Add whichever you like and get rid of the Red exclamation that is next to ADMIN

upload_2017-12-20_14-52-19.png


3. Add a Host
As mentioned, Rancher is a way of managing a Docker cluster or cattle as they call it. So before beginning to add containers we need to add a host.
INFRASTRUCTURE > Hosts > Add Host

upload_2017-12-20_14-55-14.png


Fill in your IP in number 4 and that will update field 5. Copy the code by pressing the blue button on the end of field 5. Head back to your terminal which should still be logged in to your RancherOS machine and paste and run that command.

Almost immediately you should see a Host on the Infrastructure > Hosts Screen within Rancher UI
upload_2017-12-20_14-57-1.png


4 Mounting Volume - New Method
So your containers will need access to your Volumes within FreeNAS. The way we do this is by:
  • Creating a share on FreeNAS (I've got some SMB/CIFS shares)
  • Mounting shares to RancherOS
  • containers in Docker can map to those mounted volumes within RancherOS
Create a plex user within FreeNAS
  • Our example uses username = plex and password = plexpassword. Replace these with your own values
  • give it READ access to where your media is
  • give it WRITE access to where you want PLEX to store it's config and transcode folders

The Way to mount the storage is:
  1. Create a YAML file
  2. Merge it with the config
  3. Restart RancherOS

When ready create a file somewhere called mount.yaml:
Code:
vi mount.yaml


Press i to get into insert mode

Add the following lines:
Code:
mounts:
- - //10.1.2.250/Videos
  - /media/videos
  - cifs
  - username=plex,password=plexpassword,iocharset=utf8,_netdev
- - //10.1.2.250/Pictures
  - /media/pictures
  - cifs
  - username=plex,password=plexpassword,iocharset=utf8,_netdev
- - //10.1.2.250/Backups
  - /media/backups
  - cifs
  - username=plex,password=plexpassword,iocharset=utf8,_netdev


Replace the directories / IP with your own. If I look at the code above:
  • I'm mapping the Videos share on FreeNAS (10.1.2.250)
  • to the /media/videos directory in my host (RancherOS)
  • using the CIFS protocol / driver
  • with the username of the share being plex
  • and the password of the share being plexpassword
  • etc
Cool story right?

Press ESC then :x to save and exit

Now run:
sudo ros config merge -i mount.yaml

Replace with your share(s)IP and credentials ofcourse.
Now Storage will persist even on reboot.

Be sure to reboot RancherOS for your volumes to show up.

you should see your shares mounted to the host (RancherOS) by typing:
df -h

upload_2017-12-20_15-8-39.png


5. Add a container
Enough with the Faffing. Let's add a PLEX container

To get a container up and running you basically need:
  • Volumes - Where the (persistent) storage for the container is
  • Networking - Type of networking you'd like (bridge is generally default, but PLEX recommends host)
  • Ports - Which ports you want forwarded into the container
  • Environment Variables - variables the container needs
Go back to your browser to the RancherUI and go to:
INFRASTRUCTURE > Containers > Add Container

Enter the following:
  • Name - plex (or whatever you like)
  • Description - optional but nice
  • Select Image - plexinc/pms-docker

Click the Plus Button under Port Map and Map the Port:
  • 32400 to 32400
This forward the requests sent to the host on 32400 to the 32400 port in the container

Come down to the Command Tab
Click the plus button to add Environment Variables:

TZ - Timezone
PLEX_CLAIM - A claim token for signing in which can be obtained from https://www.plex.tv/claim/

upload_2017-12-20_15-21-59.png



Go to the Volumes Tab
And map the Volumes like so:

These are the minimum ones you need
  • /data - where does your media exist? We mapped this in the steps above
  • /config - where PLEX config lives
  • /transcode - where PLEX transcode files live

upload_2017-12-20_15-23-30.png


**UPDATED**
Go to the Networking Tab and set:
  • Network - host
  • DNS - Enable Rancher DNS service discovery
  • Hostname - Whatever you'd like the hostname to be (ensure this hostname doesn't already exist on your network)
  • Resolving Servers - Your router / DNS server
upload_2017-12-24_9-56-56.png



Click Create!!!!!!!!!!

Rancher will go and pull the PLEX image and spin everything up according to your settings.

If you mess something up, you cannot edit any of these settings. You will have to CLONE your container and change what you need to. I haven't had much success with cloning so I used to destroy and create from scratch.

Anyway, access your plex by going to:
  • 10.1.2.252:32400
Or whatever your RancherOS IP is.

Have fun :)
 

Attachments

  • upload_2017-12-20_14-50-44.png
    upload_2017-12-20_14-50-44.png
    43.6 KB · Views: 1,213
Last edited:

Koen

Cadet
Joined
Jan 5, 2015
Messages
1
Hello Yusuf,

Thanks for your guide !!
I will give it a try next weekend
 

Varun Chugh

Dabbler
Joined
Dec 15, 2015
Messages
38
help! I am getting stuck at the first step itself. see screenshot. after doing a cu, it says connected but doesn't go beyond that.
 

Attachments

  • Screen Shot 2017-12-20 at 7.55.03 PM.png
    Screen Shot 2017-12-20 at 7.55.03 PM.png
    50.7 KB · Views: 1,206

silverback

Contributor
Joined
Jun 26, 2016
Messages
134
Thanks for sharing, really wanted persistant storage with cifs.
 

vikozo6

Patron
Joined
Oct 16, 2015
Messages
290
I have got a small Problem at
3. Add a Host
As mentioned, Rancher is a way of managing a Docker cluster or cattle as they call it. So before beginning to add containers we need to add a host.
INFRASTRUCTURE > Hosts > Add Host

I do not have a public IP ;-(
the Public IP of my Router is used to point to my Web, DNS, Mail server....
 

Yusuf Limalia

Patron
Joined
Apr 5, 2016
Messages
234
I have got a small Problem at
3. Add a Host
As mentioned, Rancher is a way of managing a Docker cluster or cattle as they call it. So before beginning to add containers we need to add a host.
INFRASTRUCTURE > Hosts > Add Host

I do not have a public IP ;-(
the Public IP of my Router is used to point to my Web, DNS, Mail server....

You need to use the IP of the RancherOS host.
If you run:

ifconfig eth0 | grep 'inet addr'

In your RancherOS terminal, what do you see?
 

Varun Chugh

Dabbler
Joined
Dec 15, 2015
Messages
38
Hit the return key a few times.

:)

hey @Yusuf Limalia tried doing that more than a few times :) to no effect. when I check the dataset, I dont see any images. Could it be that the img didnt download? The VM says its running. I tried creating more VMs but the output is the same.

Is there any place where freenas downloads the VM template or something? Would try deleting that and creating the VM again.
 

Yusuf Limalia

Patron
Joined
Apr 5, 2016
Messages
234
hey @Yusuf Limalia tried doing that more than a few times :) to no effect. when I check the dataset, I dont see any images. Could it be that the img didnt download? The VM says its running. I tried creating more VMs but the output is the same.

Is there any place where freenas downloads the VM template or something? Would try deleting that and creating the VM again.

Check this post:

https://forums.freenas.org/index.php?threads/freenas-11-1-rancher-server-installation-failed.59898/
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Hi Yusuf,

Nice post, pity about not using the Rancher-NFS storage plugin. What problems did you encounter with it? It can, and does work. I'm slowly getting to grips with it and that's not helped by the rancher docs which are clear as mud at times. Judging by posts at https://github.com/rancher/rancher/issues it's evolved quite fast.

PS Did you ever consider using either of these?
1. the rancheros volumes-nfs service which uses the docker-volume-netshare container

https://github.com/ContainX/docker-volume-netshare

Code:
root@rancher:~# ros service list 
disabled amazon-ecs-agent 
disabled crontab 
disabled open-iscsi 
disabled kernel-extras 
disabled kernel-headers 
disabled kernel-headers-system-docker 
disabled open-vm-tools 
disabled rancher-server 
disabled rancher-server-stable 
disabled zfs 
disabled amazon-metadata 
disabled volume-cifs 
disabled volume-efs 
disabled volume-nfs 
enabled  bhyve-vm-tools


or

2. this docker nfs3-client?

https://hub.docker.com/r/d3fk/nfs-client/ eg: https://bmccarthy.net/2017/10/09/ra...to-stop-worrying-and-love-the-docker-compose/
 

Yusuf Limalia

Patron
Joined
Apr 5, 2016
Messages
234
Hi Yusuf,

Nice post, pity about not using the Rancher-NFS storage plugin. What problems did you encounter with it? It can, and does work. I'm slowly getting to grips with it and that's not helped by the rancher docs which are clear as mud at times. Judging by posts at https://github.com/rancher/rancher/issues it's evolved quite fast.

PS Did you ever consider using either of these?
1. the rancheros volumes-nfs service which uses the docker-volume-netshare container

https://github.com/ContainX/docker-volume-netshare

Code:
root@rancher:~# ros service list
disabled amazon-ecs-agent
disabled crontab
disabled open-iscsi
disabled kernel-extras
disabled kernel-headers
disabled kernel-headers-system-docker
disabled open-vm-tools
disabled rancher-server
disabled rancher-server-stable
disabled zfs
disabled amazon-metadata
disabled volume-cifs
disabled volume-efs
disabled volume-nfs
enabled  bhyve-vm-tools


or

2. this docker nfs3-client?

https://hub.docker.com/r/d3fk/nfs-client/ eg: https://bmccarthy.net/2017/10/09/ra...to-stop-worrying-and-love-the-docker-compose/


Sorry I updated this post earlier, but the layout was confusing. Thanks for bringing it up! I've updated it now so it should make more sense
I'm using rancher's native way of mounting the cifs shares now (see step 4 above) and it's working fine :)
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Sorry I updated this post earlier, but the layout was confusing. Thanks for bringing it up! I've updated it now so it should make more sense
I'm using rancher's native way of mounting the cifs shares now (see step 4 above) and it's working fine :)

Fine, but does "docker volume ls" at the rancher CL show all your volumes as local? Because I'm talking about using the rancher-nfs driver, eg.:

Code:
root@rancher:~# docker volume ls
DRIVER			  VOLUME NAME
local			   3cfd8a17a7edfe257a7e04768289057dba1d895a5eef1347408a2c018a8bb313
local			   6e5a4b80c9373b2bb04e55ab02baa34754f30b77c24fd71f692953ba22b41279
rancher-nfs		 LMS-Music
rancher-nfs		 LMS-State
local			   e17486817a28882935b2af26dcaf712362a5f4b5d9e02903794f8f8f0754e661
rancher-nfs		 music
local			   rancher-agent-state
local			   rancher-cni
local			   rancher-cni-driver
rancher-nfs		 test
 

vikozo6

Patron
Joined
Oct 16, 2015
Messages
290
my share where my videos are is a SMB share so what do i have to change, too?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
my share where my videos are is a SMB share so what do i have to change, too?
Nothing. SMB and CIFS are effectively the same thing.
 

Tobinger

Cadet
Joined
Dec 21, 2017
Messages
1
Hi Yusuf,

many thanks for this perfect tutorial! :)
It helped me very much to run Libresonic on FreeNAS and setup up the shares. I think this will help many people after me.
 
Last edited by a moderator:

Yusuf Limalia

Patron
Joined
Apr 5, 2016
Messages
234
Fine, but does "docker volume ls" at the rancher CL show all your volumes as local? Because I'm talking about using the rancher-nfs driver, eg.:

Code:
root@rancher:~# docker volume ls
DRIVER			  VOLUME NAME
local			   3cfd8a17a7edfe257a7e04768289057dba1d895a5eef1347408a2c018a8bb313
local			   6e5a4b80c9373b2bb04e55ab02baa34754f30b77c24fd71f692953ba22b41279
rancher-nfs		 LMS-Music
rancher-nfs		 LMS-State
local			   e17486817a28882935b2af26dcaf712362a5f4b5d9e02903794f8f8f0754e661
rancher-nfs		 music
local			   rancher-agent-state
local			   rancher-cni
local			   rancher-cni-driver
rancher-nfs		 test

Ah I see! No using ros config -merge with the mounts in the yaml don't show the drives under there.

1) Is there any difference in using rancher-nfs?
2) How do you mount a share using rancher-nfs? Im all ears!
 

vikozo6

Patron
Joined
Oct 16, 2015
Messages
290
hello yusuf
step 4 add a host

Code:
[rancher@rancher ~]$ sudo docker run -e CATTLE_HOST_LABELS='host4='  --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.7 https://10.147.42.130:8080/v1/scripts/49F7E6AE249F00566EB6:1483142400000:uowA1LfGFxULopYkFMVTlYdEko

6

INFO: Running Agent Registration Process, CATTLE_URL=https://10.147.42.130:8080/v1
INFO: Attempting to connect to: https://10.147.42.130:8080/v1
ERROR: https://10.147.42.130:8080/v1 is not accessible (server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none)
ERROR: https://10.147.42.130:8080/v1 is not accessible (server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none)
 

Varun Chugh

Dabbler
Joined
Dec 15, 2015
Messages
38
I did get past this. Now I am stuck at 'no space left on disk'. But I have GBs of space on the disk. Any idea? Sorry for the trouble. all attached the screenshot.
and one more image for reference when I try and install the Rancher system I get the same no space left error. Please help!
 

Attachments

  • Screen Shot 2017-12-22 at 3.48.36 PM.png
    Screen Shot 2017-12-22 at 3.48.36 PM.png
    335.4 KB · Views: 930
Top