LMLPHP后院

traffmonetizer 小鸡折腾记技术

maybe yes 发表于 2023-07-24 09:39

今天尝试了下 traffmonetizer 小鸡折腾记录,给大家参考一下。

安装前的 ifstat 查看下。

pi@raspberrypi:~ $ ifstat
       eth0               wlan0              docker0           veth8924a78             tun0       
 KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out
    0.00      0.00      2.57      4.31      0.00      0.00      0.00      0.00      0.00      0.00
    0.00      0.00      0.95      1.43      0.00      0.00      0.00      0.00      0.00      0.00
^C

我选择了 docker,觉得 linux 平台会稍微靠谱一点点,可能是我多虑了。

pi@raspberrypi:~ $ docker pull traffmonetizer/cli:arm64v8
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/create?fromImage=traffmonetizer%2Fcli&tag=arm64v8": dial unix /var/run/docker.sock: connect: permission denied

第一个命令,安装,没有加 sudo ,添加就好了。

pi@raspberrypi:~ $ sudo docker pull traffmonetizer/cli:arm64v8
arm64v8: Pulling from traffmonetizer/cli
c41833b44d91: Pull complete 
9926c042f50a: Pull complete 
45d6644da518: Pull complete 
4f4fb700ef54: Pull complete 
4bbba162c046: Pull complete 
b3c922416e21: Pull complete 
Digest: sha256:6b52d15cc334a59cae6c243fa6ede483cb94673f7888efa0f9d62f74fc2a7eb8
Status: Downloaded newer image for traffmonetizer/cli:arm64v8
docker.io/traffmonetizer/cli:arm64v8

查看下容器和 images。

pi@raspberrypi:~ $ sudo docker ps -a
CONTAINER ID   IMAGE          COMMAND   CREATED         STATUS                      PORTS                                           NAMES
f1942ea329f4   80b10a6d5299   "bash"    10 months ago   Up 6 months                 0.0.0.0:519->12406/tcp, :::519->12406/tcp   goofy_beaver
c272b3d6a428   python         "bash"    10 months ago   Exited (137) 9 months ago                                                   amazing_hugle
pi@raspberrypi:~ $ sudo docker images
REPOSITORY                     TAG       IMAGE ID       CREATED         SIZE
traffmonetizer/cli             arm64v8   00f33c480d40   5 weeks ago     29.5MB
<none>                         <none>    80b10a6d5299   10 months ago   937MB
python                         latest    1b564c42cc2f   10 months ago   868MB
ubuntu                         latest    21735dab04ba   10 months ago   69.2MB
malaohu/ssr-with-net-speeder   latest    88f555b7b31d   5 years ago     412MB

第一次运行,竟然失败了。

pi@raspberrypi:~ $ docker run -i --name tm traffmonetizer/cli start accept --token Rxx --device-name traffmonetizer_eight
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=tm": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
pi@raspberrypi:~ $ sudo docker run -i --name tm traffmonetizer/cli start accept --token Rxx --device-name traffmonetizer_eight
Unable to find image 'traffmonetizer/cli:latest' locally
latest: Pulling from traffmonetizer/cli
4db1b89c0bd1: Pull complete 
b9e403a3ddb8: Pull complete 
f3bcb6468097: Pull complete 
4f4fb700ef54: Pull complete 
5317128756d5: Pull complete 
dd72171523e0: Pull complete 
Digest: sha256:7114b73838077303e14ac834d2e5c7e2491be388c2578752593f1ffef1c8a8db
Status: Downloaded newer image for traffmonetizer/cli:latest
WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested
standard_init_linux.go:228: exec user process caused: exec format error

究其原因,因为我参考 docker 页面文档输入命令,不知道运行后为什么会下错了平台,可能是下载了 AMD 的 traffmonetizer/cli last 来运行,导致错误。来查看一下 images。

pi@raspberrypi:~ $ sudo docker images
REPOSITORY                     TAG       IMAGE ID       CREATED         SIZE
traffmonetizer/cli             arm64v8   00f33c480d40   5 weeks ago     29.5MB
traffmonetizer/cli             latest    e4911939c3c7   5 weeks ago     29.1MB
<none>                         <none>    80b10a6d5299   10 months ago   937MB
python                         latest    1b564c42cc2f   10 months ago   868MB
ubuntu                         latest    21735dab04ba   10 months ago   69.2MB
malaohu/ssr-with-net-speeder   latest    88f555b7b31d   5 years ago     412MB
pi@raspberrypi:~ $ sudo docker image rm e4911939c3c7
Error response from daemon: conflict: unable to delete e4911939c3c7 (must be forced) - image is being used by stopped container dab449c2ecba
pi@raspberrypi:~ $ sudo docker rm e4911939c3c7
Error: No such container: e4911939c3c7
pi@raspberrypi:~ $ sudo docker images rm e4911939c3c7
"docker images" requires at most 1 argument.
See 'docker images --help'.

Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

List images
pi@raspberrypi:~ $ sudo docker image rm e4911939c3c7
Error response from daemon: conflict: unable to delete e4911939c3c7 (must be forced) - image is being used by stopped container dab449c2ecba
pi@raspberrypi:~ $ sudo docker ps -a
CONTAINER ID   IMAGE                COMMAND                  CREATED              STATUS                          PORTS                                           NAMES
dab449c2ecba   traffmonetizer/cli   "./Cli start accept …"   About a minute ago   Exited (1) About a minute ago                                                   tm
f1942ea329f4   80b10a6d5299         "bash"                   10 months ago        Up 6 months                     0.0.0.0:519->12406/tcp, :::519->12406/tcp   goofy_beaver
c272b3d6a428   python               "bash"                   10 months ago        Exited (137) 9 months ago                                                       amazing_hugle
pi@raspberrypi:~ $ sudo docker stop dab449c2ecba
dab449c2ecba
pi@raspberrypi:~ $ sudo docker ps -a
CONTAINER ID   IMAGE                COMMAND                  CREATED              STATUS                          PORTS                                           NAMES
dab449c2ecba   traffmonetizer/cli   "./Cli start accept …"   About a minute ago   Exited (1) About a minute ago                                                   tm
f1942ea329f4   80b10a6d5299         "bash"                   10 months ago        Up 6 months                     0.0.0.0:519->12406/tcp, :::519->12406/tcp   goofy_beaver
c272b3d6a428   python               "bash"                   10 months ago        Exited (137) 9 months ago                                                       amazing_hugle
pi@raspberrypi:~ $ sudo docker rm dab449c2ecba
dab449c2ecba


pi@raspberrypi:~ $ sudo docker ps -a
CONTAINER ID   IMAGE          COMMAND   CREATED         STATUS                      PORTS                                           NAMES
f1942ea329f4   80b10a6d5299   "bash"    10 months ago   Up 6 months                 0.0.0.0:519->12406/tcp, :::519->12406/tcp   goofy_beaver
c272b3d6a428   python         "bash"    10 months ago   Exited (137) 9 months ago                                                   amazing_hugle
pi@raspberrypi:~ $ sudo docker image rm e4911939c3c7
Untagged: traffmonetizer/cli:latest
Untagged: traffmonetizer/cli@sha256:7114b73838077303e14ac834d2e5c7e2491be388c2578752593f1ffef1c8a8db
Deleted: sha256:e4911939c3c7f9b114962604018739a6e17d47ab244ce2611682d2429f5493e6
Deleted: sha256:d9c858e93c621c8d03d88a5383cb02575c05e251480c463bddd3c3120cc775e8
Deleted: sha256:90143918d170d1d2979f48467271c0cdd3e71007b17031b39666450203f5ad81
Deleted: sha256:4306b32798a9dcd29329931a478d20b40ff3fbbf3482334f8cecca4b9369bd10
Deleted: sha256:2503b09754aef6bcdc5089a87a8b6f463e0dfd012ad8befb57efb06ab07032ce
Deleted: sha256:6e87a355fe5cdc5066221fc704ea396e81395b5bf21ba0bb512a4547c856e040
Deleted: sha256:3dab9f8bf2d28c8bd1047f3ac2d0c72f3570562f491e67ef8179dfdcc68bccff

删除了容器后,删除 image。

pi@raspberrypi:~ $ sudo docker image -a
unknown shorthand flag: 'a' in -a
See 'docker image --help'.

Usage:  docker image COMMAND

Manage images

Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

Run 'docker image COMMAND --help' for more information on a command.

pi@raspberrypi:~ $ ^C
pi@raspberrypi:~ $ sudo docker image

Usage:  docker image COMMAND

Manage images

Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

Run 'docker image COMMAND --help' for more information on a command.
pi@raspberrypi:~ $ sudo docker images
REPOSITORY                     TAG       IMAGE ID       CREATED         SIZE
traffmonetizer/cli             arm64v8   00f33c480d40   5 weeks ago     29.5MB
<none>                         <none>    80b10a6d5299   10 months ago   937MB
python                         latest    1b564c42cc2f   10 months ago   868MB
ubuntu                         latest    21735dab04ba   10 months ago   69.2MB
malaohu/ssr-with-net-speeder   latest    88f555b7b31d   5 years ago     412MB

pi@raspberrypi:~ $ docker run -i --name tm 00f33c480d40 start accept --token Rxx --device-name traffmonetizer_eight
docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/containers/create?name=tm": dial unix /var/run/docker.sock: connect: permission denied.
See 'docker run --help'.
pi@raspberrypi:~ $ sudo docker run -i --name tm 00f33c480d40 start accept --token Rxx --device-name traffmonetizer_eight
Token: Rxx; Id: 37d8f501-4769-4759-a202-db422d956362

^Cpi@raspberrypi:~ $ sudo docker run -d --name tm 00f33c480d40 start accept --token Rxx --device-name traffmonetizer_eight
docker: Error response from daemon: Conflict. The container name "/tm" is already in use by container "1f5b90943c33d36228a68d971ab2ce4c2b32dc500c9001e3722a9353e18ab517". You have to remove (or rename) that container to be able to reuse that name.
See 'docker run --help'.
pi@raspberrypi:~ $ sudo docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS                        PORTS                                           NAMES
1f5b90943c33   00f33c480d40   "./Cli start accept …"   About a minute ago   Exited (130) 20 seconds ago                                                   tm
f1942ea329f4   80b10a6d5299   "bash"                   10 months ago        Up 6 months                   0.0.0.0:519->12406/tcp, :::519->12406/tcp   goofy_beaver
c272b3d6a428   python         "bash"                   10 months ago        Exited (137) 9 months ago                                                     amazing_hugle
pi@raspberrypi:~ $ sudo docker rm 1f5b90943c33
1f5b90943c33
pi@raspberrypi:~ $ sudo docker ps -a
CONTAINER ID   IMAGE          COMMAND   CREATED         STATUS                      PORTS                                           NAMES
f1942ea329f4   80b10a6d5299   "bash"    10 months ago   Up 6 months                 0.0.0.0:519->12406/tcp, :::519->12406/tcp   goofy_beaver
c272b3d6a428   python         "bash"    10 months ago   Exited (137) 9 months ago                                                   amazing_hugle
pi@raspberrypi:~ $ sudo docker run -d --name tm 00f33c480d40 start accept --token Rxx --device-name traffmonetizer_eight
8d5cbfb4eb0fb27bda58edeec0065752ae28fc2455609df5bcc4417842ffde51
pi@raspberrypi:~ $ 
pi@raspberrypi:~ $ sudo docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS                      PORTS                                           NAMES
8d5cbfb4eb0f   00f33c480d40   "./Cli start accept …"   6 seconds ago   Up 4 seconds                                                                tm
f1942ea329f4   80b10a6d5299   "bash"                   10 months ago   Up 6 months                 0.0.0.0:519->12406/tcp, :::519->12406/tcp   goofy_beaver
c272b3d6a428   python         "bash"                   10 months ago   Exited (137) 9 months ago                                                   amazing_hugle

上面就是删除了下载错误的 image 后,重启修改了启动命令,指定了 image id 来启动,搞定。最后使用 -d 命令后台运行,完美。

traffmonetizer 小鸡折腾记

查看下 ifstat

pi@raspberrypi:~ $ ifstat
       eth0               wlan0              docker0           veth8924a78             tun0            veth633f0ad    
 KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out   KB/s in  KB/s out
    0.00      0.00      0.60      0.77      0.00      0.06      0.00      0.00      0.00      0.00      0.00      0.06
    0.00      0.00      0.05      0.24      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
    0.00      0.00      0.05      0.24      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
    0.00      0.00      0.57      1.06      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
    0.00      0.00      1.89      3.07      0.15      0.17      0.00      0.00      0.00      0.00      0.17      0.17
    0.00      0.00      0.18      0.33      0.00      0.00      0.00      0.00      0.00      0.00      0.00      0.00
    0.00      0.00      0.45      0.75      0.27      0.40      0.00      0.00      0.00      0.00      0.32      0.40
^C

CPU 略有上升,多了一个虚拟网卡。

2024-10-12 23:23:40 1728746620 0.021457