【问题标题】:Linuxkit where is the container runningLinuxkit 容器在哪里运行
【发布时间】:2022-08-15 08:44:42
【问题描述】:

Linuxkit 是一个非常有趣的项目,所以开始使用它。我使用 redis-os.yml 示例 https://raw.githubusercontent.com/linuxkit/linuxkit/master/examples/redis-os.yml 创建了图像

当我启动 redis-os 时它可以工作,但我没有看到任何 redis 服务器容器,我发现 redis 正在运行但无法找到位置。

(ns: getty) linuxkit-f6b2836a15cb:~# pstree
init-+-containerd---7*[{containerd}]
     |-containerd-shim-+-tini---rungetty.sh-+-rungetty.sh---login---sh
     |                 |                    `-rungetty.sh---login---sh---bash--+
     |                 `-11*[{containerd-shim}]
     `-containerd-shim-+-redis-server---3*[{redis-server}]
                       `-11*[{containerd-shim}]

.当我运行列表容器时,我没有看到任何 redis 容器

  (ns: getty) linuxkit-f6b2836a15cb:~# runc list
    ID           PID         STATUS      BUNDLE                          CREATED                         OWNER
    000-dhcpcd   0           stopped     /containers/onboot/000-dhcpcd   2022-08-12T21:38:05.40297821Z   root

我可以看到 redis 在端口上监听

(ns: getty) linuxkit-f6b2836a15cb:~# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN      421/redis-server
tcp        0      0 :::6379                 :::*                    LISTEN      421/redis-server

问题是 redis 容器在哪里,我如何获取配置文件或 exec 容器文件系统?

  • 我不知道 LinuxKit,但我想它依赖于 Linux 命名空间。如果您需要查看正在运行的容器列表,则需要在主机端。您的示例似乎表明您在容器内运行命令。因此,您看不到超出它的内容。

标签: linux containers runc linuxkit


【解决方案1】:

我想通了,是的,它在命名空间中,但与 docker 命令相比,语法并不复杂。

(ns: getty) linuxkit-fa163e26c0e8:~# ctr -n services.linuxkit t exec -t --exec-id bash_1 redis sh
/data # redis-cli
127.0.0.1:6379> PING
PONG
127.0.0.1:6379>

【讨论】:

    猜你喜欢
    • 2023-03-31
    • 1970-01-01
    • 2019-05-19
    • 2019-11-28
    • 1970-01-01
    • 2022-12-22
    • 1970-01-01
    • 1970-01-01
    • 2020-01-02
    相关资源
    最近更新 更多