I am running Fedora Server with Docker installed, and it has a folder that connects to my NAS via SMB. I will have all of my Docker files (and Compose configs) stored on my NAS, since it has a lot more storage. I am worried that Docker will glitch out and cause a mess, since my NAS starts ~2 minutes later than my server from a reboot. Is there something that I can do to make sure Docker is able to connect to the SMB share safely?

  • cereals@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    5 months ago

    I would use NFS instead of SMB. you will have all sorts of problems when you use smb, primarily permissions.

    Also I wouldn’t put all the data on the nas. What containers do you want to run? If you try to run something like nextcloud, you can just map your data directory to your nas. Databases, configfiles and so on aren’t that big usually and your application will be a lot faster when those are on your local storage instead of the nas. For actually mapping your containers data to your nas you can just use bind mounts.

    For the startup, you can set restart:never in your compose file and start the container with a script after bootup where you out something like ‘sleep 120’ in the beginning.

  • Max-P@lemmy.max-p.me
    link
    fedilink
    arrow-up
    2
    ·
    5 months ago

    Make Docker depend on the mount. You can simply use systemctl edit docker.service and then

    [Unit]
    Requires=path-to-your-smb.mount
    After=path-to-your-smb.mount
    

    Then it will guarantee it’s mounted by the time Docker starts.

    • Mountain_Mike_420@lemmy.ml
      link
      fedilink
      arrow-up
      1
      ·
      22 days ago

      This is the answer. I’m not sure you need both. I tried the Requires= but that didn’t solve my problem till I did After= Thanks for the heads up!

      • Max-P@lemmy.max-p.me
        link
        fedilink
        arrow-up
        2
        ·
        22 days ago

        It does need both. Requires= alone will only pull the unit as a dependency and will activate it, but doesn’t define a hard dependency. You need the After= to also declare that the unit must be started after its dependencies are finished loading, not merely being activated. Otherwise they will start in parallel, it just guarantees that both units will be activated. There’s an even stronger directive, BindsTo=, that will tie them such that if its dependency is stopped, this unit will be deactivated too. If SMB is a hard dependency that might be preferable. Requires+After still allows the mount to fail, but ensures if it’s mountable it’ll be mounted before Docker, whereas with BindsTo+After, failing the SMB mount would also shut down Docker.

  • breadsmasher@lemmy.world
    link
    fedilink
    English
    arrow-up
    1
    ·
    5 months ago

    Not personally used docker and SMB in that exact setup, but I would approach it as leaving the server to deal with SMB etc and docker to handle the volume after the fact.

    But do you mean you have all your docker compose files on a different server connected via SMB, and from your host server running docker, so it needs to access the external SMB server?

    I wouldn’t set it up like this. Config data itself should be negligible. Are you concerned with docker image data storage usage? Because your setup of having the configs elsewhere I believe wouldn’t solve the image size storage needs since the docker host would still pull them down