以下为官方安装文档:https://jellyfin.org/docs/general/installation/container

1. 下载最新的容器镜像。


```
docker pull jellyfin/jellyfin

```

2. 为配置和缓存数据创建持久存储。


在主机上创建两个目录并使用绑定挂载:

mkdir ./path/to/config -p
mkdir ./path/to/cache -p

或者创建两个持久卷:

docker volume create jellyfin-config
docker volume create jellyfin-cache

3、 通过以下方式之一创建并运行容器。

注意:Docker 的默认网络模式是桥接模式。如果省略主机模式,则将使用桥接模式。使用主机网络 ( --net=host) 是可选的,但必须使用 DLNA 才能使用。
一、使用 Docker 命令行界面:

docker run -d \
--name jellyfin \
--user uid:gid \
--net=host \
--volume /path/to/config:/config \ # Alternatively --volume jellyfin-config:/config
--volume /path/to/cache:/cache \ # Alternatively --volume jellyfin-cache:/cache
--mount type=bind,source=/path/to/media,target=/media \
--restart=unless-stopped \
jellyfin/jellyfin

正确命令:

docker run -d --name jellyfin --net=host --volume ./path/to/config:/config --volume ./path/to/cache:/cache --mount type=bind,source=/mnt/sda/smba,target=/media1 --mount type=bind,source=/mnt/sdb/av250G,target=/media2,readonly --restart=unless-stopped jellyfin/jellyfin

需要使用绑定挂载将文件夹从主机操作系统传递到容器操作系统,而卷由 Docker 维护,可以认为更容易通过外部程序备份和控制。对于简单的设置,使用绑定挂载比使用卷更容易。如果需要,可以绑定挂载多个媒体库:


- -mount type=bind,source=/path/to/media1,target=/media1
--mount type=bind,source=/path/to/media2,target=/media2,readonly
...etc

二、使用 Docker compose
创建一个docker-compose.yml包含以下内容的文件。在下面的用户行中添加您想要运行 jellyfin 的 UID 和 GID,或者删除用户行以使用默认用户(root)。


version: '3.5'
services:
jellyfin:
image: jellyfin/jellyfin
container_name: jellyfin
user: uid:gid
network_mode: 'host'
volumes:
- /path/to/config:/config
- /path/to/cache:/cache
- type: bind
source: /path/to/media
target: /media
- type: bind
source: /path/to/media2
target: /media2
read_only: true
restart: 'unless-stopped'
# Optional - alternative address used for autodiscovery
environment:
- JELLYFIN_PublishedServerUrl=http://example.com
# Optional - may be necessary for docker healthcheck to pass if running in host network mode
extra_hosts:
- 'host.docker.internal:host-gateway'

然后在docker-compose.yml运行相同的文件夹中:
docker compose up
要在后台运行容器,请添加-d上述命令。
访问目标计算机ip:8096即可进入jellyfin界面。

标签: none

添加新评论