7

没有装Docker如何从镜像中释放出文件

 2 years ago
source link: https://zhangrr.github.io/posts/20211027-docker_extract_file/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

没有装Docker如何从镜像中释放出文件

2021-10-27 2 分钟阅读

用 kubernetes 越多,用 docker 越多,就愈发感觉到好处多多。

简简单单的一个可执行文件,用 docker 基板 alphine 封装,就可以运行起一个 pod ,然后指定 deployment、svc、ingress,就可以将服务暴露出去。

其实很多情况下单可执行文件 + systemd也是不错的选择。

这不就遇到个问题,ghostunnel 这个软件,github 只释放出了源代码以及 windows 、linux 和 mac 的三个可执行版本。

可我的执行环境是 nanopi ,是个 arm7 的架构,就无计可施了。

无奈下,在 nanopi 上装了 go ,编译了个 arm7 的出来。

但是遇到 vaultwanden ,rust 的,就没法弄了,vps 太弱,根本无法用 cargo 编译。

那怎么办呢?方法如下,不安装 Docker ,也可以把镜像中的文件抽取出来

$ mkdir vm
$ wget https://raw.githubusercontent.com/jjlin/docker-image-extract/main/docker-image-extract
$ chmod +x docker-image-extract
$ ./docker-image-extract vaultwarden/server:alpine
Getting API token...
Getting image manifest for vaultwarden/server:alpine...
Fetching and extracting layer a0d0a0d46f8b52473982a3c466318f479767577551a53ffc9074c9fa7035982e...
Fetching and extracting layer 3a9a529931676767ec84d35ab19774b24bd94e20f6fff7e6bda57ef5f2a66cfc...
Fetching and extracting layer f9dcfa9aefe67ce52ab2a73e515ea715d242348b8fc338dbe4ca72a853ea0318...
Fetching and extracting layer 4249d8cece35148b5faca2c6a98d566a271a1996b127b14480793ee8825e43c0...
Fetching and extracting layer 72f4873a62cc82eaf28905077df3791e3b235bf5d17670e7aff6d5fb5e280739...
Fetching and extracting layer 8eb772c524f9d998c8c7c92acc5ba96e3e9ebfb175dbb2441fe6e7b7598874f5...
Fetching and extracting layer 663794f103b44abb8a90e1376dce14735905e2f938b4ca7e0ff379b09cbf6148...
Image contents extracted into ./output.

shell

这样我们就可以在 output 目录下得到 vaultwarden 和 web-vault

image-20211027172244666

如果我们要拿到 arm7 的镜像,还需要再费点劲,以 ghostunnel 为例:

访问: https://hub.docker.com/r/ghostunnel/ghostunnel/tags

找到 linux/arm/v7 的 tag,40247f4b49c3

image-20211027172546788

点开后,找到 DIGEST: ,复制sha256以及后面的字串,sha256:40247f4b49c364046ebf47696dbd31752b4db2ae2b9edf1fd4c52c2573f06e04

image-20211027172728110

按如下方法释放即可:

$ ./docker-image-extract ghostunnel/ghostunnel:sha256:40247f4b49c364046ebf47696dbd31752b4db2ae2b9edf1fd4c52c2573f06e04
shell

不用担心目录结构,释放出来的文件会放到当前 output 目录下。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK