Category Archives: Docker
Running multiple plex containers in Docker
Original: https://www.reddit.com/r/unRAID/comments/vo0qim/does_plex_need_to_be_run_in_host_mode/
When you have the network type “host” for a docker container then you are telling docker that the Image or container itself will manage the ports. This means that an -P
or -p XXXX
port assignment is ignored. Any port in the docker image marked with EXPOSED will be, well, exposed as port in the container with network type “host”.
Another thing to note here is that the container has the same IP as the host. So if your Host has the IP 192.168.0.5
then the container will also have that IP and the Ports are accessible directly on 192.168.0.5:XXXX
With the network type “bridge” this is a bit different. First, each container will get its own IP in the docker network, this can be 172.17.0.X
. Unlike with network type “host”, you, who run the docker command, are responsible to expose the ports, not the image. This means that now the -P
and -p
parameters work and have to be used so that ports are being exposed. For plex, this can mean double or multiple NATing which can interfere with remote access.
In Unraid, the template is just a more user-friendly way to construct the docker run command (which also gets shown when you create a new container and click apply). In the template, you have the ability to add a new configuration like a port.
If no ports are being exposed in bridge mode then I would check the template if any ports are actually exposed. If not then you need to add them. In host mode, as said above, this is not necessary because it will do this on its own depending on what is defined in the image.
Lastly, this is specifically to Plex Media Server, I would recommend using Host mode here for its simplicity. Plex determines stream locations based on where you connect from through the IP that is accessing the server. If those IPs are not in the same network then Plex will consider them as remote streams and all of the settings in regards to remote streams (like quality) apply.
This means that even if your Plex client is on your TV, in the same room as your Plex Server, when you have the Plex Media Server running in a Docker container that has the network mode “bridge” then those IPs are not in the same network (even though they physically are) and plex considers that client a “remote” stream. This means, when you haven’t changed your remote streaming quality, you could end up streaming a 720p and most likely a transcode.
You can prevent that by telling Plex in the Plex server settings -> Network -> “LAN Networks” to consider an IP or IP address range to be considered a Local network.
I have three Plex instances running and only my main one is on host mode, the others are (and have to be) in bridge mode so that I can change the Port or else there would be a conflict because you can’t listen to the same port with two applications. But that also means that those other instances are constantly considered Remote unless I say they are local as described above.
Meet netboot.xyz – Network Boot Any Operating System
Debugging .NET Containers with Visual Studio Code Docker Tools
Prometheus Monitoring – Steps to monitor third-party apps using Prometheus Exporter | Part 2
Prometheus monitoring stack on Ubuntu 22.04.2 and Micro Kubernetes Cluster (microk8s)
1) Install Ubuntu 22.04.2 desktop
Install guest agent:
sudo apt-get install qemu-guest-agent sudo systemctl start qemu-guest-agent
Optional – Add the curret user to the sudo group:
sudo usermod -aG sudo $USER
2) Configure RDP and VNC
fix the lock problem:
3) Install docker
sudo apt install docker.io
add the current user to docker group:
sudo usermod -aG docker $USER
4) Check docker version
docker --version
5) Create a Micro Kubernetes Cluster (microk8s)
See here: https://microk8s.io/docs/getting-started
sudo snap install microk8s --classic --channel=1.27
MicroK8s creates a group to enable seamless usage of commands which require admin privilege. To add your current user to the group and gain access to the .kube caching directory, run the following two commands:
sudo usermod -a -G microk8s $USER sudo chown -f -R $USER ~/.kube
See the node:
microk8s kubectl get nodes
See the running services:
microk8s kubectl get services
Create an alias:
alias kubectl='microk8s kubectl'
Deploy an app:
microk8s kubectl create deployment nginx --image=nginx microk8s kubectl get pods
Starting and Stopping MicroK8s:
microk8s stop microk8s start
export the cluster configuration
kubectl config view --raw > ~/.kube/config
6) Alternatively – install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube_latest_amd64.deb sudo dpkg -i minikube_latest_amd64.deb
start your cluster:
minikube start
Install kubectl:
snap install kubectl --classic kubectl version --client
7) Install helm
$ curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 $ chmod 700 get_helm.sh $ ./get_helm.sh
or using snap:
sudo snap install helm --classic
8) Deploy Prometheus monitoring stack to Kubernetes with a single Helm Chart
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update kubectl create ns prom helm search repo prometheus-community helm install prometheus prometheus-community/kube-prometheus-stack -n prom helm install ksm prometheus-community/kube-state-metrics -n prom # install the kube-state-metrics kubectl --namespace prom get pods
Check configmaps and secrets:
kubectl --namespace prom get configmap kubectl --namespace prom get secret
Look inside a secret file:
kubectl --namespace prom get secret
Check CRDs
kubectl get crd
9) Access Prometheus Dashboard
$ kubectl port-forward -n prom service/prometheus-kube-prometheus-prometheus 9090
10) Access Grafana Dashboard
$ kubectl port-forward -n prom deployment/prometheus-grafana 3000
default user/password is admin/prom-operator
11) Uninstall Prometheus stack
$ helm uninstall ksm -n prom $ helm uninstall prom -n prom
12) Install and use K8S Lens to explore what was deployed in the kluster:
Install Docker in WSL 2 without Docker Desktop