简体   繁体   中英

Getting runc config.json from docker container

I am trying to create a runc container from a docker container.

I followed this blog post and was successfull in extracting the config.json from the running docker container.

The issue is that

  1. The path where I found the config.json was different then the references I found online
  2. The same path does not work on a different host which has, as far as I can tell, the same docker version. On that host, I have not been able to find where the config.json is generated.

I have conflicting information on where to find the config.json, and am unable to find it on my host.

|config.json location                     | source                         |
|-----------------------------------------|--------------------------------------------|
|/run/docker/libcontainerd/<container id> | http://crunchtools.com/getting-ninja-runc/ |
|/var/run/docker/libcontainerd/<container id> |https://github.com/genuinetools/riddler |
|/var/run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby/<container id> | my host #1 |
| ??? | my host #2 |

What other locations can I check, and how can I tell which one it will be? Is this configured somewhere, does this depend on the version of docker, containerd, runc, or something else?

I found config.json here:

/run/containerd/io.containerd.runtime.v1.linux/moby/container_id/config.json

on ubuntu18.04, docker version:

Client: Docker Engine - Community
 Version:           19.03.4
 API version:       1.40
 Go version:        go1.12.10
 Git commit:        9013bf583a
 Built:             Fri Oct 18 15:54:09 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.4
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.12.10
  Git commit:       9013bf583a
  Built:            Fri Oct 18 15:52:40 2019
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.10
  GitCommit:        b34a5c8af56e510852c35414db4c1f4fa6172339
 runc:
  Version:          1.0.0-rc8+dev
  GitCommit:        3e425f80a8c931f88e6d94a8c831b9d5aa481657
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683

@lin.qian 's answer saves me hours. config.json is now located in /run/containerd/io.containerd.runtime.v1.linux/moby/ rather than all the other locations mentioned in the question post.

Actually if you further want to use this config file with runc, you need modify

  • root

and remove the following from "mounts"

  • "/etc/hosts"
  • "/etc/hostname"
  • "/dev/shm"

and remove "hooks"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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