(无根)runc容器的网络设置

时间:2019-03-08 14:07:51

标签: networking runc

我正在尝试从docker映像创建(理想情况下是无根的)runc容器,但是生成的容器无法通过网络进行通信。如何为容器设置网络?

我尝试使用netns作为预启动钩子,但无法正常工作。除此之外,我尝试了激活/停用命名空间和功能的过程,但是没有运气。

作为根文件系统,我正在使用导出的ubuntu docker映像。

config.json

{
    "ociVersion": "1.0.0-rc5-dev",
    "root": {
        "path": "rootfs",
        "readonly": false
    },
    "process": {
        "args": [
            "bash", "./startup.sh", "mathPublisher_ecal"
        ],
        "cwd": "/app",
        "env": [
            "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
            "TERM=xterm"
            ],
        "oomScoreAdj": 0,
        "terminal": true,
        "user": {
            "gid": 0,
            "uid": 0
            },
        "noNewPrivileges": true,
        "capabilities": {
            "bounding": [
                "CAP_MKNOD",
                "CAP_NET_RAW",
                "CAP_KILL",
                "CAP_AUDIT_WRITE", 
            ],
            "effective": [
                "CAP_MKNOD",
                "CAP_NET_RAW",
                "CAP_KILL",
                "CAP_AUDIT_WRITE"
            ],
            "inheritable": [
                "CAP_MKNOD",
                "CAP_NET_RAW",
                "CAP_KILL",
                "CAP_AUDIT_WRITE"
            ],
            "permitted": [
                "CAP_MKNOD",
                "CAP_NET_RAW",
                "CAP_KILL",
                "CAP_AUDIT_WRITE"
            ]
        },
        "rlimits": [
            {
                "type" : "RLIMIT_AS",
                "soft" : 419430400,
                "hard" : 419430400
            }
        ]
    },
    "hooks": {
        "prestart" : [
            {
                "path" : "/path/to/netns",
                "args" : [
                    "",
                    "--state-dir", "/path/to/netns/netns-state"
                ]

            }
        ]
    },
    "linux": {
        "uidMappings": [
            {
                "hostID": 500101175,
                "containerID": 0,
                "size": 1
            }
        ],
        "gidMappings": [
            {
                "hostID": 513,
                "containerID": 0,
                "size": 1
            }
        ],
        "maskedPaths": [
            "/proc/asound",
            "/proc/acpi",
            "/proc/kcore",
            "/proc/keys",
            "/proc/latency_stats",
            "/proc/timer_list",
            "/proc/timer_stats",
            "/proc/sched_debug",
            "/proc/scsi",
            "/sys/firmware"
        ],
        "namespaces": [
            {
                "type": "mount"
            },
            {
                "type": "uts"
            },
            {
                "type": "pid"
            },
            {
                "type": "ipc"
            },
            {
                "type": "user"
            }
        ],
    "readonlyPaths": [
        "/proc/bus",
        "/proc/fs",
        "/proc/irq",
        "/proc/sys",
        "/proc/sysrq-trigger"
        ]
    },
    "mounts": [
        {
            "destination": "/proc",
            "options": [
            "nosuid",
            "noexec",
            "nodev"
            ],
            "source": "proc",
            "type": "proc"
        },
        {
            "destination": "/dev",
            "options": [
                "nosuid",
                "strictatime",
                "mode=755",
                "size=65536k"
            ],
            "source": "tmpfs",
            "type": "tmpfs"
        },
        {
            "destination": "/dev/pts",
            "options": [
            "nosuid",
            "noexec",
            "newinstance",
            "ptmxmode=0666",
            "mode=0620"
            ],
            "source": "devpts",
            "type": "devpts"
        },
        {
            "destination": "/sys",
            "source": "/sys",
            "options": [
                "rbind",
                "nosuid",
                "noexec",
                "nodev",
                "ro"
            ],
            "type": "none"
        },
        {
            "destination": "/sys/fs/cgroup",
            "options": [
                "ro",
                "nosuid",
                "noexec",
                "nodev"
            ],
            "source": "cgroup",
            "type": "cgroup"
        },
        {
            "destination": "/dev/mqueue",
            "options": [
                "nosuid",
                "noexec",
                "nodev"
            ],
            "source": "mqueue",
            "type": "mqueue"
        }
    ]
}

这给我的是错误

container_linux.go:348: starting container process caused "process_linux.go:402: container init caused \"process_linux.go:385: running prestart hook 0 caused \\\"error running hook: exit status 1, stdout: , stderr: renaming interface ethc21652 to eth0 failed: file exists\\\\n\\\"\""

0 个答案:

没有答案