docker学习应用-02

参考链接

【好玩儿的Docker项目】用腾讯云轻量应用服务器10分钟搭建一个轻量的视频分享网站——Fireshare (laoda.de)

轻量级服务器购买:https://loll.cc/tx

[root@VM-24-16-centos ~]# docker --help

Usage: docker [OPTIONS] COMMAND

A self-sufficient runtime for containers
Common Commands:
  run         Create and run a new container from an image
  exec        Execute a command in a running container
  ps          List containers
  build       Build an image from a Dockerfile
  pull        Download an image from a registry
  push        Upload an image to a registry
  images      List images
  login       Log in to a registry
  logout      Log out from a registry
  search      Search Docker Hub for images
  version     Show the Docker version information
  info        Display system-wide information
Management Commands:
  builder     Manage builds
  buildx*     Docker Buildx (Docker Inc., v0.10.2)
  compose*    Docker Compose (Docker Inc., v2.16.0)
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  plugin      Manage plugins
  scan*       Docker Scan (Docker Inc., v0.23.0)
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes
Swarm Commands:
  swarm       Manage Swarm
Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  wait        Block until one or more containers stop, then print their exit codes
Global Options:
      --config string      Location of client config files (default "/root/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default
                           context set with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit
Run 'docker COMMAND --help' for more information on a command.
For more help on how to use Docker, head to https://docs.docker.com/go/guides/

放行5244端口

登录

docker使用命令:

docker ps -a
docker image ls 

docker inspect dd26419089a6 查看容器信息
"HostsPath": "/var/lib/docker/containers/dd26419089a6f00fc363bd4
[root@VM-24-16-centos ~]# docker inspect  dd26419089a6
[
    {
        "Id": "dd26419089a6f00fc363bd48079c324396be11f94007c23c12757b032
        "Created": "2023-02-25T14:55:24.726537004Z",
        "Path": "/entrypoint.sh",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 10072,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2023-02-25T14:55:25.14528093Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:ec73a6569021673383e84ce8a4377239d0eadddfe4c900f
        "ResolvConfPath": "/var/lib/docker/containers/dd26419089a6f00fc3
        "HostnamePath": "/var/lib/docker/containers/dd26419089a6f00fc363
        "HostsPath": "/var/lib/docker/containers/dd26419089a6f00fc363bd4
        "LogPath": "/var/lib/docker/containers/dd26419089a6f00fc363bd480bd48079c324396be11f94007c23c12757b0325de355c-json.log",
        "Name": "/alist",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": [
                "/etc/alist:/opt/alist/data"
            ],
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {
                "5244/tcp": [
                    {
                        "HostIp": "",
                        "HostPort": "5244"
                    }
                ]
            },
            "RestartPolicy": {
                "Name": "always",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "ConsoleSize": [
                30,
                129
            ],
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": [],
            "BlkioDeviceWriteBps": [],
            "BlkioDeviceReadIOps": [],
            "BlkioDeviceWriteIOps": [],
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/face520cb3c4835c8dr/lib/docker/overlay2/55c9b5ffc8fc4636e0a17022a974dc5a7c98dc70eb696f58f8e8de23efca541fc7ca9145dcffdf84b57abec1ce01901a214/diff:/var/lib/docker/oa04cc83d91ca/diff:/var/lib/docker/overlay2/41a26d0448b4ff9244c54e7ecc3ccrlay2/8744e8a7719e7acd655d30581d2f9916ea6e0ffe48dfc941fb6a691b66518aa8/d
                "MergedDir": "/var/lib/docker/overlay2/face520cb3c4835c8
                "UpperDir": "/var/lib/docker/overlay2/face520cb3c4835c8d
                "WorkDir": "/var/lib/docker/overlay2/face520cb3c4835c8d3
            },
            "Name": "overlay2"
        },
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/etc/alist",
                "Destination": "/opt/alist/data",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        "Config": {
            "Hostname": "dd26419089a6",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "ExposedPorts": {
                "5244/tcp": {}
            },
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PUID=0",
                "PGID=0",
                "UMASK=022",
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:
            ],
            "Cmd": null,
            "Image": "xhofe/alist:latest",
            "Volumes": {
                "/opt/alist/data/": {}
            },
            "WorkingDir": "/opt/alist",
            "Entrypoint": [
                "/entrypoint.sh"
            ],
            "OnBuild": null,
            "Labels": {
                "MAINTAINER": "i@nn.ci",
                "org.opencontainers.image.created": "2023-02-25T10:07:37
                "org.opencontainers.image.description": "🗂️A file list plidjs. / 一个支持多存储的文件列表程序,使用 Gin 和 Solidjs。",
                "org.opencontainers.image.licenses": "AGPL-3.0",
                "org.opencontainers.image.revision": "81e10f8939861390e2
                "org.opencontainers.image.source": "https://github.com/a
                "org.opencontainers.image.title": "alist",
                "org.opencontainers.image.url": "https://github.com/alis
                "org.opencontainers.image.version": "v3.12.2"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "60f87480024310942bafef940a38976ffc5c7dd2745402
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {
                "5244/tcp": [
                    {
                        "HostIp": "0.0.0.0",
                        "HostPort": "5244"
                    },
                    {
                        "HostIp": "::",
                        "HostPort": "5244"
                    }
                ]
            },
            "SandboxKey": "/var/run/docker/netns/60f874800243",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "9a0690c4f695a4349d30dab10a97024bcc6b881b021d5
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "459c946814fae2a9e268f1f4608db43902f2de
                    "EndpointID": "9a0690c4f695a4349d30dab10a97024bcc6b8
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

在返回的json数据中,查找 Path 和HostPath这两个参数:

其中,Path 为容器的运行位置(指令),HostPath 为容器的所在位置。

Fireshare视频网站

提前安装好宝塔面板海外版本aapanel,并安装好Nginx(安装地址)

安装好Nginx Proxy Manager(相关教程)

参考这边的内容:https://blog.laoda.de/archives/nginxproxymanager

sudo -i # 切换到root用户
apt update -y  # 升级packages
apt install wget curl sudo vim git -y  # Debian系统比较干净,安装常用的软件

创建安装目录及docker-compose文件

version: '3.7'
services:
  fireshare:
    container_name: fireshare
    image: shaneisrael/fireshare:latest    # latest表示最新版本
    ports:
      - "8080:80"        # 冒号左边的端口可以自己修改成服务器未占用的端口,冒号右边不要改!
    volumes:
      - ./data:/data         # 冒号左边的路径可以自己修改(./代表当前目录下),冒号右边不要改!
      - ./processed:/processed # 同上
      - ./videos:/videos  # 同上
    environment:
    - ADMIN_USERNAME=admin    # 自己设置一个用户名
    - ADMIN_PASSWORD=admin    # 自己修改一个密码
Fireshare需要3个卷挂载。
/data - fireshare用来保存其内部数据库的目录
/processed - 用来保存由fireshare创建的与你的视频有关的元数据的目录(海报,元数据信息)。
/videos - fireshare将观察和扫描任何视频的目录
如果你有你所有的游戏片段存储在一个文件夹my_game_clips中,那么在你的docker compose文件(或docker运行命令)中,你将需要把该文件夹卷装到fireshare观看的/videos文件夹。

新建文件夹 fireshare 和 子目录


mkdir -p /root/data/docker_data/fireshare/{data,processed,videos}
# 进入目录
cd /root/data/docker_data/fireshare
ls -al
# 确保 docker-compose.yml 在当前目录下

测试Linux端口的是否可访问的四种方法_fengzelun的博客-CSDN博客_linux测试端口是否可用

打开8080端口

lsof -i:8080  #查看8080端口是否被占用,如果被占用,重新自定义一个端口

如果端口没有被占用(被占用了就修改一下端口,比如改成8081,注意dockercompose和防火墙都要改),我们接着可以运行:

apt install lsof  #安装lsof

拉去镜像

重新更新当前镜像

cd /root/data/docker_data/fireshare

docker-compose up -d  
重新更新当前镜像

我们就可以输入http://ip:8080访问了。

注意:

1、不知道服务器IP,可以直接在命令行输入:curl ip.sb,会显示当前服务器的IP。
2、遇到访问不了的情况,请再次检查在宝塔面板的防火墙和服务商的后台防火墙是否打开对应了端口。

反向代理————-还没完成

购买域名

而且namesilo上面xyz后缀的域名一年就7块钱,可以年抛。
如果想要长期使用,还是建议买com后缀的域名,更加正规一些,可以输入laodade来获得1美元的优惠(不知道现在还有没有)
namesilo自带隐私保护,咕咕一直在用这家,价格也是这些注册商里面比较低的,关键是他家不像其他家域名注册商,没有七七八八的套路!(就是后台界面有些丑古老 = =)

【服务器、域名购买】Namesilo优惠码和域名解析教程(附带服务器购买推荐和注意事项) (laoda.de)

因为我们后续想要分享给别人,IP+端口太不优雅了,咕咕建议大家还是搞一个域名,容易记,看起来也更正规一点。这样可以做https,会让网页更安全。(非要IP+端口访问的,可以直接跳到5.6,并且跳过6. 反向代理部分)

利用filebrowser来上传视频。

mkdir -p /root/data/docker_data/filebrowser
docker run -d -v /root/data/docker_data/fireshare/videos:/srv -v /root/data/docker_data/filebrowser/filebrowserconfig.json:/etc/config.json -v /root/data/docker_data/filebrowser/database.db:/etc/database.db --name fireshare_browser -p 8002:80 filebrowser/filebrowser

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

哈都婆

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值