简体   繁体   English

Podman:对 podman config.json 所做的更改不会在容器启动时持续存在

[英]Podman: Changes made to podman config.json do not persist on container start

I am trying to add a network to a podman container after it has already been created.我正在尝试在创建 podman 容器后将网络添加到它。 These are the steps I took:这些是我采取的步骤:

  • Create and start a container:创建并启动一个容器:
podman run -it --name "container" --network=mgmtnet img_v1 /bin/bash
  • The container starts.容器启动。
  • I now stop the container我现在停止容器
    podman stop container
  • I edit the podman config.json file at: /var/lib/containers/storage/overlay-containers/60dfc044f28b0b60f0490f351f44b3647531c245d1348084944feaea783a6ad5/userdata/config.json I edit the podman config.json file at: /var/lib/containers/storage/overlay-containers/60dfc044f28b0b60f0490f351f44b3647531c245d1348084944feaea783a6ad5/userdata/config.json

I add an extra netns path in the namespaces section.我在命名空间部分添加了一个额外的 netns 路径。

"namespaces": [
            {
                "type": "pid"
            },
            {
                "type": "network",
>>              "path": "/var/run/netns/cni-8231c733-6932-ed54-4dee-92477014da6e",
>>[+]           "path": "/var/run/netns/test_net"
            },
            {
                "type": "ipc"
            },
            {
                "type": "uts"
            },
            {
                "type": "mount"
            }
        ],
  • I start the container我启动容器
podman start container

I expected the changes (an extra interface) in the container.我期望容器中的更改(一个额外的接口)。 But that doesn't happen.但这不会发生。 Also, checking the config.json, I find that my changes are gone.此外,检查 config.json,我发现我的更改已经消失。

So starting the container removes the changes in config.因此启动容器会删除 config.xml 中的更改。 How to overcome this?如何克服这一点?

Extra info:额外信息:

[root@bng-ix-svr1 ~]# podman info
host:
  BuildahVersion: 1.9.0
  Conmon:
    package: podman-1.4.2-5.module+el8.1.0+4240+893c1ab8.x86_64
    path: /usr/libexec/podman/conmon
    version: 'conmon version 2.0.1-dev, commit: unknown'
  Distribution:
    distribution: '"rhel"'
    version: "8.1"
  MemFree: 253316108288
  MemTotal: 270097387520
  OCIRuntime:
    package: runc-1.0.0-60.rc8.module+el8.1.0+4081+b29780af.x86_64
    path: /usr/bin/runc
    version: 'runc version spec: 1.0.1-dev'
  SwapFree: 5368705024
  SwapTotal: 5368705024
  arch: amd64
  cpus: 16
  hostname: bng-ix-svr1.englab.juniper.net
  kernel: 4.18.0-147.el8.x86_64
  os: linux
  rootless: false
  uptime: 408h 2m 41.08s (Approximately 17.00 days)
registries:
  blocked: null
  insecure: null
  search:
  - registry.redhat.io
  - registry.access.redhat.com
  - quay.io
  - docker.io
store:
  ConfigFile: /etc/containers/storage.conf
  ContainerStore:
    number: 4
  GraphDriverName: overlay
  GraphOptions: null
  GraphRoot: /var/lib/containers/storage
  GraphStatus:
    Backing Filesystem: xfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Using metacopy: "false"
  ImageStore:
    number: 2
  RunRoot: /var/run/containers/storage
  VolumePath: /var/lib/containers/storage/volumes

that is correct.那是对的。 The config.json file is generated by Podman to instruct the OCI runtime how to run the container. Podman 生成 config.json 文件,用于指示 OCI 运行时如何运行容器。

All the changes done directly on that file will be lost next time you restart the container.下次重新启动容器时,直接对该文件所做的所有更改都将丢失。 The config.json file is used by the OCI runtime to create the container and then it is not used anymore. OCI 运行时使用 config.json 文件来创建容器,然后不再使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM