Docker builds Plex streaming media service and plays your own local videos

Docker builds Plex streaming media service

  1. Install Docker
  2. Create a directory to store configuration files
  3. Create a Plex container
  4. Configure Plex
  5. Set up media library
  6. Visit Plex

1 Introduction

Plex is a streaming server that makes it easy to stream your library of media files (such as movies, TV shows, and music) over the network to a variety of devices.

  • Plex is a set of media player and media server software that provides a complete set of solutions (Server + Client). It supports many platforms and devices and has almost no requirements on the performance of mobile devices. Any device that can open the web and watch videos will basically All can be used. Plex supports remote access, cloud synchronization and friend sharing library functions, which is especially suitable for home audio and video libraries and long-distance couples watching movies.

Other similar software:

  • emby (charged)
  • Jellyfin (charged)
  • elfilm (free, not open source)
  • infuse (charged)

The scraper is called an agent in plex

2 Installation and deployment process

2.1 Install Docker

If it is Windows or Mac, you can directly install the docker desktop software
Official website address: https://www.docker.com/products/docker-desktop/

If it is Linux (Ubuntu or CentOS):
Prerequisites:

  • Docker can run on Windows, Mac, CentOS, Ubuntu and other operating systems

  • Docker supports the following CentOS versions:

    • CentOS 7 (64-bit)
    • CentOS 6.5 (64-bit) or higher
  • Currently, CentOS only supports Docker in the kernel in the distribution

    • Docker runs on CentOS 7, which requires the system to be 64-bit and the system kernel version to be 3.10 or above.
    • Docker runs on CentOS-6.5 or higher, which requires the system to be 64-bit and the system kernel version to be 2.6.32-431 or higher.
  1. Check the system kernel

The uname command is used to print current system-related information (kernel version number, hardware architecture, host name, operating system type, etc.).

uname -r
  1. View installed CentOS version information
cat /etc/redhat-release

It can be installed if it meets the above conditions for installing docker.
Docker official website:
Official website: http://www.docker.com

Installation manual: https://docs.docker.com/install/linux/docker-ce/centos (CE-Community Edition)

① Install the required software packages

yy-utils provides yy-config-manager related functions, device-mapper-persistent-data and lvm2 are required by the device mapper driver.

yum install -y yum-utils \
               device-mapper-persistent-data \
               lvm2

如果有以下报错信息:

Error: Another app is currently holding the yum lock; waiting for it to exit... Another app is: PackageKit Memory: 146 M RSS (497 MB VSZ) Started: Wed Oct 26 20:20:11 2022 - 00:07 Previous status: Running, process ID: 2874 Another app is currently holding the yum lock; waiting for

Just execute the following command:

rm -f /var/run/yum.pid
② Set the docker image to Alibaba Cloud and update the yum index

①Set the docker image to Alibaba Cloud

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

②After we update or configure the yum source, we usually use yum makecache to generate a cache. This command caches the software package information locally in advance to improve the speed of searching and installing software.

yum makecache fast
③ Docker installation is subsequent configuration

①Install docker ce

yum install -y docker-ce

②Start docker

systemctl start docker

③Check docker version

docker version

④ Set whether docker is enabled or not

#查看服务是否自动启动(是:enabled | 否:disabled)
systemctl list-unit-files|grep docker.service 

#设置开机启动:如不是enabled可以运行如下命令设置自启动
systemctl enable docker
#重新加载服务配置
systemctl daemon-reload 

#如果希望不进行自启动,运行如下命令设置
systemctl disable docker
#重新加载服务配置
systemctl daemon-reload 

⑤If we want to uninstall docker, execute the following command

systemctl stop docker 
yum remove -y docker-ce
rm -rf /var/lib/docker

Extension: Sometimes, we need different servers to deploy the same image. At this time, we can use docker export / import to import and export the image.

Export:

docker export f299f501774c > rabbit.tar

Import:

docker import - myrabbit < rabbit.tar

2.2 Create configuration file directory

Create a directory on your system to store Plex configuration files. You can create a directory using the following command:

# 创建plex配置文件
mkdir -p /Users/ziyi/plex-config
# 创建自己本地存放媒体的文件夹
mkdir -p /Users/ziyi/media

2.3 docker creates plex

docker run -d \
  --name plex \
  --restart=unless-stopped \
  -p 32400:32400 \
  -v /Users/ziyi/plex-config:/config \
  -v /Users/ziyi/media:/data \
  plexinc/pms-docker

-d: Run the container in the background;
–name plex: Specify the name of the container as "plex";
–restart=unless- stopped: Automatically restart after the container is stopped or restarted;
-p 32400:32400: Map the host's 32400 port to the container's 32400 port, which is the default port of Plex;
-v /Users/ziyi/plex-config:/config: Mount the "plex-config" directory on the host to the "/config" directory of the container to store Plex configuration files;
-v /Users/ziyi/media:/data: Mount the "media" directory on the host to the "/data" directory of the container to store media files.
Please replace /Users/ziyi/plex-config and /Users/ziyi/media in the above command with the actual directory paths.

# 查看plex是否启动成功,出现Up表明成功,否则表明失败
docker ps | grep plex

Insert image description here

2.4 Configuration and access

①Register or log in to plex account

You can now access Plex's web interface by visiting http://localhost:32400/web. When accessing for the first time, you will need to log in or create a Plex account.

  • If you don’t have an account, you can register via email

Insert image description here

After logging in, follow the instructions on the interface to complete the initial setup of Plex. You can set the server name, language, media library, etc.

Once Plex is configured, you can add your media folders through the "Add Media Library" option. Click the "Add Media Library" button, select the media type (such as movies, TV shows, music, etc.), and then select the corresponding media folder.

Plex will scan and index the media files in the selected folder and display them on the web interface.

✈️Plex工作原理:
Insert image description here

You can browse and play your media files on Plex's web interface or watch them on a variety of devices using the Plex client app.

②Access

You can now access your Plex server through your browser or Plex client. Visit http://localhost:32400/web in your browser, or use the Plex client app.

  • The homepage will have videos recommended by Plex itself

Insert image description here

Insert image description here

③Add your own local database (optional)

If we want to play our own local videos on plex, we can do so by adding a library

  1. Add database

Click on the avatar - select the account - select the media library under the management module - click to add the library

Insert image description here
2. Select the corresponding media type and language
Insert image description here
3. Add a folder

Specify which folder to scan for media videos in this database

  • My local media videos are all under /Users/ziyi/media. When I started creating docker, I had bound the /Users/ziyi/media directory to the /data directory inside the plex container, so here I directly selected /data
  • Mount volume parameters when creating a container:-v /Users/ziyi/media:/data

Insert image description here

I have added my local library and can click Scan Library to scan local videos into plex.

Insert image description here
4. Return to the homepage and play the video in your own media library
Insert image description here

Play:
Insert image description here

❓tips:

  • Manually scan files on the homepage
    Insert image description hereConfigure automatic scanning of local media files and update them
    Insert image description here

Guess you like

Origin blog.csdn.net/weixin_45565886/article/details/133966975