Overslaan naar inhoud
  • +31 653-919-302
Cafayate.Net
  • 0
  • 0
  • Aanmelden
  • Nederlands English (US) Español (AR)
  • Contact
  • Startpagina
  • Blog
  • Vacatures
  • Contact
Cafayate.Net
  • 0
  • 0
    • Startpagina
    • Blog
    • Vacatures
    • Contact
  • +31 653-919-302
  • Nederlands English (US) Español (AR)
  • Aanmelden
  • Contact

Exposing a directory on the host machine to an LXC container

  • Alle blogs
  • Tech Blog
  • Exposing a directory on the host machine to an LXC container
  • 5 maart 2021 in
    Administrator
    1. Log into the container and create an empty directory, this will be the mount point
    2. Log out and stop the container.
    3. Open to your container’s config file
      • For regular LXC containers: /var/lib/lxc/mycontainer/config
      • For unprivileged LXC containers: $HOME/.local/share/lxc/mycontainer/config
    4. Add a new line above the lxc.mount directive, that follows the format below. Substitute proper paths as necessary:
      • lxc.mount.entry = /path/to/folder/on/host /path/to/mount/point none bind 0 0
      • Both of these paths are relative to the host machine.
      • Location of the root fs in the container can be found at:
        • For regular LXC containers: /var/lib/lxc/mycontainer/rootfs/
        • For unprivileged LXC containers: $HOME/.local/share/lxc/mycontainer/rootfs

    Note: If the host’s user does not exist in the container, the container will still be mounted, but with nobody:nogroup as the owner. This may not be a problem unless you need to write to these files, in which case you’ll need to give everybody write permission to that folder. (i.e. chmod -R go+w /folder/to/share)

    Example

    I want to share /home/julianlam/foobar to my unprivileged container bazquux. In bazquux, I want this folder to be found at /mnt/baz.

    In the container:

    $ cd /mnt
    $ sudo mkdir baz
    $ logout

    In the host, I will add the following line above lxc-mount in /home/julianlam/.local/share/lxc/bazquux/config:

    lxc.mount.entry = /home/julianlam/foobar /home/julian/.local/share/lxc/bazquux/rootfs/mnt/baz none bind 0 0
    
    

    Then

    $ lxc-start -n bazquux -d

    Further Reading

    • https://wiki.debian.org/LXC

     

    “If the host’s user does not exist in the container, the container will still be mounted, but with nobody:nogroup” I have the exact same problem. Can you please elaborate how to get past this issue?

     

    in Tech Blog
    Odoo What is the difference between odoo snippets v8 and v9

    Ontworpen voor bedrijven

    We zijn een team van gepassioneerde mensen met als doel levens te verbeteren met vernieuwende producten. We ontwikkelen geweldige oplossingen voor al je zakelijke uitdagingen. Onze producten zijn ontworpen voor kleine tot middelgrote bedrijven die hun prestaties willen optimaliseren.

    Neem contact op

    Plantexel
    Pedernera
    Salta Capital 
    Argentina

    • +31 653-919-302
    • [email protected]
    Volg ons
    Copyright © Plantexel
    Nederlands | English (US) | Español (AR)