Skip to content

Problem to share a container mount with host #2877

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pwFoo opened this issue Jan 20, 2018 · 1 comment
Open

Problem to share a container mount with host #2877

pwFoo opened this issue Jan 20, 2018 · 1 comment

Comments

@pwFoo
Copy link

pwFoo commented Jan 20, 2018

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?

@pwFoo
Copy link
Author

pwFoo commented Jan 20, 2018

mount namespace is also set if I test docker.yml, but it works... Is there some magic in the linuxkit/init?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant