Skip to content

Problem to share a container mount with host  #2877

Open
@pwFoo

Description

@pwFoo

Description

I try to share a container mount with the host like done with docker example mount in onboot section.

Steps to reproduce the issue:

Generated a custom mount image (alpine image)

onboot section

  - name: mount
    image: alpine:latest
    capabilities:
    - CAP_SYS_ADMIN
    binds:
    - /dev:/dev
    - /var:/var:rshared,rbind
    rootfsPropagation: shared
    command:
    - "/bin/mount"
    - "LABEL=<MY_LABEL>"
    - "/var/lib/docker"

Also tested with config by image label:

LABEL org.mobyproject.config='{"binds": ["/dev:/dev", "/var:/var:rshared,rbind", "/:/hostroot"], "capabilities": ["CAP_SYS_ADMIN"], "rootfsPropagation": "shared", "net": "new", "ipc": "new"}'

Same result

Describe the results you received:

Mount inside of the container, but isn't available in the host

/ # df
Filesystem           1K-blocks      Used Available Use% Mounted on

rbind is set twice

        {                          
            "destination": "/var",
            "type": "bind",  
            "source": "/var",
            "options": [ 
                "rshared",
                "rbind", 
                "rbind"      
            ] 
        },  

namespaces and rootfsPropagation:

    "linux": {                       
        "resources": {},             
        "namespaces": [              
            {                        
                "type": "pid"                                                  
            },
            {
                "type": "mount"   
            }                         
        ],                            
        "rootfsPropagation": "shared"
    }

Describe the results you expected:

Mount should be available in host root filesystem

How to fix it

Remove mount namespace lines from config.json and run with runc run again and it will work

            {
                "type": "mount"   
            } 

And it works fine

/ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda1             10252256     36888   9674868   0% /var/lib/docker

Is it a bug or is something wrong with my yml file?
Is it possible to set mount namespace as needed in yml?

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