Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Aug 14, 2020. It is now read-only.
This repository was archived by the owner on Aug 14, 2020. It is now read-only.

Docker volume are not just mount points. #141

@yifan-gu

Description

@yifan-gu

From the Docker docs

Volumes are initialized when a container is created. If the container’s base image contains data at the specified mount point, that existing data is copied into the new volume upon volume initialization. (Note that this does not apply when mounting a host directory.)

However,when converting the docker image to ACI, we convert the volumes as mount points, and if uses don't specify the host path for mounting, we mount an empty volume, which then hide the data in the image.

e.g.

$ sudo rkt fetch --insecure-options=image docker://gcr.io/google_containers/heapster_grafana:v2.6.0-2
$ sudo rkt cat-image
$ sudo rkt image cat-manifest --pretty-print sha512-875d2c3df246
{
    "acKind": "ImageManifest",
    "acVersion": "0.7.0",
    "name": "gcr.io/google_containers/heapster_grafana",
    "labels": [
        {
            "name": "version",
            "value": "v2.6.0-2"
        },
        {
            "name": "os",
            "value": "linux"
        },
        {
            "name": "arch",
            "value": "amd64"
        }
    ],
    "app": {
        "exec": [
            "/bin/sh",
            "-c",
            "/run.sh"
        ],
        "user": "0",
        "group": "0",
        "environment": [
            {
                "name": "PATH",
                "value": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            }
        ],
        "mountPoints": [
            {
                "name": "volume-etc-grafana",
                "path": "/etc/grafana"
            },
            {
                "name": "volume-var-lib-grafana",
                "path": "/var/lib/grafana"
            },
            {
                "name": "volume-var-log-grafana",
                "path": "/var/log/grafana"
            }
        ],
        "ports": [
            {
                "name": "3000-tcp",
                "protocol": "tcp",
                "port": 3000,
                "count": 1,
                "socketActivated": false
            }
        ]
    },
    "annotations": [
        {
            "name": "created",
            "value": "2016-03-02T10:43:14Z"
        },
        {
            "name": "appc.io/docker/registryurl",
            "value": "gcr.io"
        },
        {
            "name": "appc.io/docker/repository",
            "value": "google_containers/heapster_grafana"
        },
        {
            "name": "appc.io/docker/imageid",
            "value": "038fb819adf7ec800e5cfbea213169a50e2e843268f9404fe4abef6479adbc26"
        },
        {
            "name": "appc.io/docker/parentimageid",
            "value": "afa955fff69e95d4a2e9efa6ffb8fdadac6e5cfdbbbdeb40c0622916f479ffe3"
        },
        {
            "name": "appc.io/docker/entrypoint",
            "value": "/bin/sh -c /run.sh"
        },
        {
            "name": "appc.io/docker/tag",
            "value": "v2.6.0-2"
        }
    ]
}

$ sudo rkt image extract sha512-875d2c3df246 grafana

We can see some files exist under /etc/grafana/, which is a mount point converted from the docker image's volume:

$ ls grafana/rootfs/etc/grafana/
grafana.ini  ldap.toml

Then when we run the image, we mount an empty volume, which then hide the files.

$ sudo /opt/rkt/rkt run --insecure-options=image docker://gcr.io/google_containers/heapster_grafana:v2.6.0-2 --exec /bils -- /etc/grafana/grafana.ini
image: using image from file /opt/rkt/stage1-coreos.aci
image: using image from local store for url docker://gcr.io/google_containers/heapster_grafana:v2.6.0-2
networking: loading networks from /etc/rkt/net.d
networking: loading network default with type ptp
stage1: warning: no volume specified for mount point "volume-etc-grafana", implicitly creating an "empty" volume. This volume will be removed when the pod is garbage-collected.
stage1: warning: no volume specified for mount point "volume-var-lib-grafana", implicitly creating an "empty" volume. This volume will be removed when the pod is garbage-collected.
stage1: warning: no volume specified for mount point "volume-var-log-grafana", implicitly creating an "empty" volume. This volume will be removed when the pod is garbage-collected.
[13019.327705] ls[4]: /bin/ls: cannot access /etc/grafana/grafana.ini: No such file or directory

While when docker runs the image, the file exist:

$ docker run --entrypoint=/bin/ls gcr.io/google_containers/heapster_grafana:v2.6.0-2 /etc/grafana/grafana.ini
/etc/grafana/grafana.ini

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions