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:
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:
Set your RancherOS static IP by:
Check what your interface is (eth0 is default) by running:
When you get your interface run the following commands:
Continue with the guide and access your UI by navigating to IP:8080
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
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
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
4 Mounting Volume - New Method
So your containers will need access to your Volumes within FreeNAS. The way we do this is by:
The Way to mount the storage is:
When ready create a file somewhere called mount.yaml:
Press i to get into insert mode
Add the following lines:
Replace the directories / IP with your own. If I look at the code above:
Press ESC then :x to save and exit
Now run:
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:
5. Add a container
Enough with the Faffing. Let's add a PLEX container
To get a container up and running you basically need:
INFRASTRUCTURE > Containers > Add Container
Enter the following:
Click the Plus Button under Port Map and Map the Port:
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/
Go to the Volumes Tab
And map the Volumes like so:
These are the minimum ones you need
**UPDATED**
Go to the Networking Tab and set:
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:
Have fun :)
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:
- 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.
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
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
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
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
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
- 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:
- Create a YAML file
- Merge it with the config
- 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
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
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
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
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/
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
**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
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
Have fun :)
Attachments
Last edited: