nfs-server-alpine
A Multi-Aarch image for lightweight, highly customizable, containerized NFS server
100K+
A Multi-Aarch image for lightweight, highly customizable, containerized NFS server
This is an unofficial Multi-Aarch docker image of NFS Server created for multiplatform support. This image creates a local NFS Server to facilitate client-side data transfer. Official Website: https://wiki.linux-nfs.org
| Component | Source | Current Version |
|---|---|---|
| NFS Utils | Alpine edge/main | 2.6.4-r6 |
| Alpine Base | alpine:edge | edge |
| Architecture | Available | Tag | Status |
|---|---|---|---|
| x86-64 | ✅ | amd64-<version tag> | Tested "WORKING" |
| arm64 | ✅ | arm64v8-<version tag> | Tested "WORKING" |
| armhf | ✅ | arm32v7-<version tag> | Tested "WORKING" |
| Tag | Available | Description |
|---|---|---|
| latest | ✅ | Stable NFS releases |
| 2.6.4-r6 | ✅ | NFS Utils build version 2.6.4-r6 |
Your support encourages me to keep creating/supporting my open-source projects. If you found value in this project, you can buy me a coffee to keep me up all the sleepless nights.
- NFS requires Kernel Access. Thus this continer can be run on any physical machine & VMs but CAN NOT RUN on LXC containers.
- The first write after mounting the NFS-share takes sometime (Almost a minute). So if you immidiately try to write after mounting the share, it may seem it is hanged. But it is NOT. Give it some time.
- If you continue to use the NFS you may run into a NFS stale problem. To solve this please see THIS ARTICLE
- One container can only share One parent Directory and all its nested sub-directories. But you can't use one container to share multiple Parent directories or Drives. For this you have to deploy containers for each Parent Directory or Disk.
Here are some example snippets to help you get started creating a container.
---
services:
nfs-server:
image: mekayelanik/nfs-server-alpine:latest
container_name: nfs-server-1
environment:
- TZ=Asia/Dhaka
- ALLOWED_CLIENT=192.168.1.1/24
- NFS_MOUNT_PORT=2049
# Number of Shares without ROOT DIR
- NUMBER_OF_SHARES=2
- NFS_EXPORT_1=Movies
- NFS_EXPORT_2=Music
privileged: true
volumes:
# # Don't touch the FOLLOWING Mapping (/lib/modules). This is REQUIRED to run NFS as a container. ('sys_module' modprobe )
- /lib/modules:/lib/modules
# NFS Root directory in this container '/data' MUST BE MAPPED to a valid directory in the Host (Server Machine)
## You CAN'T use different parent directory (for example /mnt/drive2/Movies) for child shares.
### To share different Child shares on another Parent directory, you must use deploy another container. (Sorry, but this is how the NFS works)
#### To create More than one NFS server container, please use MACVLAN as given example below.
- /mnt/drive1:/data
- /mnt/drive1/Movies:/data/Movies
- /mnt/drive1/Music:/data/Music
ports:
- 2049:2049
- 111:111
- 32765-32767:32765-32767
# Don't touch the FOLLOWING Section. This is REQUIRED to run NFS as a container (cap_add).
cap_add:
- SYS_ADMIN
- SETPCAP
- ALL
restart: unless-stopped
docker run -d \
--name=nfs-server-alpine \
-e TZ=Asia/Dhaka \
-e NFS_MOUNT_PORT=2049 \
-e NUMBER_OF_SHARES=2 \
-e NFS_EXPORT_1=Movies\
-e NFS_EXPORT_2=Music\
-e TZ=Asia/Dhaka \
-e ALLOWED_CLIENT=192.168.1.1/24 \
-v /lib/modules:/lib/modules \
-v /mnt/drive1:/data \
-v /mnt/drive1/Movies:/data/Movies \
-v /mnt/drive1/Music:/data/Music \
--restart unless-stopped \
mekayelanik/nfs-server-alpine:latest
docker network create -d macvlan \
#### Set your Subnet here ####
--subnet=192.168.0.0/16 \
#### Set your Desired IP range fr this MACVLAN here. (You can set IP to your CONTAINERs from this range) ####
--ip-range=192.168.1.0/16 \
#### Set your Original Network Gateway or Router's Local IP here ####
--gateway=192.168.0.1 \
#### Set your network interface in the "parent=" (In Raspberrypi parent is 'eth0' in mordern x86 systems it is 'enp4s0'. Find yours by running "tcpdump --list-interfaces" ) & desired MACVLAN Nework name in the end (Here I have set the name to macvlan-docker) IP here ####
-o parent=eth0 macvlan-docker
---
services:
nfs-server:
image: mekayelanik/nfs-server-alpine:latest
container_name: nfs-server-1
environment:
- TZ=Asia/Dhaka
- ALLOWED_CLIENT=192.168.1.1/24
- NFS_MOUNT_PORT=2049
# Number of Shares without ROOT DIR
- NUMBER_OF_SHARES=2
- NFS_EXPORT_1=Movies
- NFS_EXPORT_2=Music
privileged: true
volumes:
# # Don't touch the FOLLOWING Mapping (/lib/modules). This is REQUIRED to run NFS as a container. ('sys_module' modprobe )
- /lib/modules:/lib/modules
# NFS Root directory in this container '/data' MUST BE MAPPED to a valid directory in the Host (Server Machine)
## You CAN'T use different parent directory (for example /mnt/drive2/Movies) for child shares.
### To share different Child shares on another Parent directory, you must use deploy another container. (Sorry, but this is how the NFS works)
#### To create More than one NFS server container, please use MACVLAN as given example below.
- /mnt/drive1:/data
- /mnt/drive1/Movies:/data/Movies
- /mnt/drive1/Music:/data/Music
ports:
- 2049:2049
- 111:111
- 32765-32767:32765-32767
# Don't touch the FOLLOWING Section. This is REQUIRED to run NFS as a container (cap_add).
cap_add:
- SYS_ADMIN
- SETPCAP
- ALL
restart: unless-stopped
hostname: nfs-server-1
domainname: local
mac_address: 14-24-34-44-54-64
networks:
macvlan-docker:
ipv4_address: 192.168.1.21
#### Network Defination ####
networks:
macvlan-docker:
name: macvlan-docker
external: True
---
services:
####### Conatiner for Share from Parent Direnctory-1 or Disk-1 #######
nfs-server-disk1:
image: mekayelanik/nfs-server-alpine:latest
container_name: nfs-server-disk1
environment:
- TZ=Asia/Dhaka
- ALLOWED_CLIENT=192.168.1.1/24
- NFS_MOUNT_PORT=2049
# Number of Shares without ROOT DIR
- NUMBER_OF_SHARES=2
- NFS_EXPORT_1=Movies
- NFS_EXPORT_2=Music
privileged: true
volumes:
### Don't touch the FOLLOWING Mapping (/lib/modules). This is REQUIRED to run NFS as a container. ('sys_module' modprobe ) ###
- /lib/modules:/lib/modules
# NFS Root directory in this container '/data' MUST BE MAPPED to a valid directory in the Host (Server Machine)
## You CAN'T use different parent directory (for example /mnt/drive2/Movies) for child shares.
### To share different Child shares on another Parent directory, you must use deploy another container. (Sorry, but this is how the NFS works)
#### To create More than one NFS server container, please use MACVLAN as given example below.
- /mnt/drive1:/data
- /mnt/drive1/Movies:/data/Movies
- /mnt/drive1/Music:/data/Music
ports:
- 2049:2049
- 111:111
- 32765-32767:32765-32767
### Don't touch the FOLLOWING Section. This is REQUIRED to run NFS as a container (cap_add). ###
cap_add:
- SYS_ADMIN
- SETPCAP
- ALL
restart: unless-stopped
hostname: nfs-server-1
domainname: local
mac_address: ab-cd-ef-ab-cd-a1
networks:
macvlan-docker:
ipv4_address: 192.168.249.101
####### Conatiner for Share from Parent Direnctory-2 or Disk-2 #######
nfs-server-disk2:
image: mekayelanik/nfs-server-alpine:latest
container_name: nfs-server-disk2
environment:
- TZ=Asia/Dhaka
- ALLOWED_CLIENT=192.168.1.1/24
- NFS_MOUNT_PORT=2049
# Number of Shares without ROOT DIR
- NUMBER_OF_SHARES=2
- NFS_EXPORT_1=Games
- NFS_EXPORT_2=Softwares
privileged: true
volumes:
# # Don't touch the FOLLOWING Mapping (/lib/modules). This is REQUIRED to run NFS as a container. ('sys_module' modprobe )
- /lib/modules:/lib/modules
# NFS Root directory in this container '/data' MUST BE MAPPED to a valid directory in the Host (Server Machine)
## You CAN'T use different parent directory (for example /mnt/drive2/Movies) for child shares.
### To share different Child shares on another Parent directory, you must use deploy another container. (Sorry, but this is how the NFS works)
#### To create More than one NFS server container, please use MACVLAN as given example below.
- /mnt/drive2:/data
- /mnt/drive2/Games:/data/Games
- /mnt/drive2/Softwares:/data/Softwares
ports:
- 2049:2049
- 111:111
- 32765-32767:32765-32767
# Don't touch the FOLLOWING Section. This is REQUIRED to run NFS as a container (cap_add).
cap_add:
- SYS_ADMIN
- SETPCAP
- ALL
restart: unless-stopped
hostname: nfs-server-disk2
domainname: local
mac_address: ab-cd-ef-ab-cd-a2
networks:
macvlan-docker:
ipv4_address: 192.168.249.102
#### Network Defination ####
networks:
macvlan-docker:
name: macvlan-docker
external: True
# To mount ROOT_DIR
sudo mount -v -o vers=4.2,loud HOST-IP:/ /mount/path/to/ROOT-MOUNT-DIR
Example: sudo mount -v -o vers=4.2,loud 192.168.1.2:/ /mount/path/to/ROOT-MOUNT-DIR
# To mount Child Shares (via Command Line)
sudo mount -v -o vers=4.2,loud HOST-IP:/Movies /nfs_shares/Movies
sudo mount -v -o vers=4.2,loud HOST-IP:/Music /nfs_shares/Music
Example:
mkdir -p /nfs_shares/Movies && \
sudo mount -v -o vers=4.2,loud 192.168.1.2:/Movies /nfs_shares/Movies
##### NFS-Share Mounts #####
192.168.249.101:/ /nfs_shares nfs nofail,noauto,x-systemd.automount
192.168.249.101:/Movies /nfs_shares/Movies nfs nofail,noauto,x-systemd.automount
192.168.249.101:/Music /nfs_shares/Music nfs nofail,noauto,x-systemd.automount
sudo umount /nfs_shares/Movies
Below are the instructions for updating containers:
docker compose pull
docker compose pull mekayelanik/nfs-server-alpine
docker compose up -d
docker compose up -d nfs-server-alpine
docker image prune
docker pull mekayelanik/nfs-server-alpine:latest
docker stop nfs-server-alpine
docker rm nfs-server-alpine
docker image prune
Pull the latest image at its tag and replace it with the same env variables in one run:
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower\
--run-once nfs-server-alpineTo remove the old unused images run: docker image prune
Note: You can use Watchtower as a solution to automated updates of existing Docker containers. But it is discouraged to use automated updates. However, this is a useful tool for one-time manual updates of containers where you have forgotten the original parameters. In the long term, it is recommend to use Docker Compose.
To submit this Docker image specific issues or requests visit this docker image's Github Link: https://github.com/MekayelAnik/nfs-server-alpine
For NFS related issues please visit: http://www.linux-nfs.org/wiki/index.php/Main_Page
Your support encourages me to keep creating/supporting my open-source projects. If you found value in this project, you can buy me a coffee to keep me up all the sleepless nights.
Content type
Image
Digest
sha256:b7cba9ecc…
Size
17.1 MB
Last updated
2 months ago
docker pull mekayelanik/nfs-server-alpine