Skip to content
This repository was archived by the owner on Oct 6, 2023. It is now read-only.

Commit 8e2ee49

Browse files
committed
loose ends before switch to Alpine
1 parent e95afec commit 8e2ee49

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ RUN apk --update --no-cache add bash nfs-utils && \
88
rm -v /etc/idmapd.conf /etc/exports
99

1010
# http://wiki.linux-nfs.org/wiki/index.php/Nfsv4_configuration
11-
RUN mkdir -p /var/lib/nfs/rpc_pipefs && \
12-
mkdir -p /var/lib/nfs/v4recovery && \
11+
RUN mkdir -p /var/lib/nfs/rpc_pipefs && \
12+
mkdir -p /var/lib/nfs/v4recovery && \
1313
echo "rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0" >> /etc/fstab && \
1414
echo "nfsd /proc/fs/nfsd nfsd defaults 0 0" >> /etc/fstab
1515

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ A lightweight, robust, flexible, and containerized NFS server.
66

77
This is the only containerized NFS server that offers **all** of the following features:
88

9+
- small (~15MB) Alpine Linux image
910
- NFS versions 3, 4, or both simultaneously
10-
- small (< 15MB) Alpine Linux image
1111
- clean teardown of services upon termination (no lingering `nfsd` processes on Docker host)
1212
- flexible construction of `/etc/exports`
1313
- extensive server configuration via environment variables
@@ -40,7 +40,7 @@ This is the only containerized NFS server that offers **all** of the following f
4040
- `nfs`
4141
- `nfsd`
4242
- `rpcsec_gss_krb5` (*only if Kerberos is used*)
43-
43+
4444
Usually you can enable these modules with: `modprobe {nfs,nfsd,rpcsec_gss_krb5}`
4545
1. The container will need to run with `CAP_SYS_ADMIN` (or `--privileged`). This is necessary as the server needs to mount several filesystems *inside* the container to support its operation, and performing mounts from inside a container is impossible without these capabilities.
4646
1. The container will need local access to the files you'd like to serve via NFS. You can use Docker volumes, bind mounts, files baked into a custom image, or virtually any other means of supplying files to a Docker container.
@@ -57,13 +57,13 @@ Starting the `erichough/nfs-server` image will launch an NFS server. You'll need
5757
--cap-add SYS_ADMIN \
5858
-p 2049:2049 \
5959
erichough/nfs-server
60-
60+
6161
Let's break that command down into its individual pieces to see what's required for a successful server startup.
6262

6363
1. **Provide the files to be shared over NFS**
6464

6565
As noted in the [requirements](#requirements), the container will need local access to the files you'd like to share over NFS. Some ideas for supplying these files:
66-
66+
6767
* [bind mounts](https://docs.docker.com/storage/bind-mounts/) (`-v /host/path/to/shared/files:/some/container/path`)
6868
* [volumes](https://docs.docker.com/storage/volumes/) (`-v some_volume:/some/container/path`)
6969
* files [baked into](https://docs.docker.com/engine/reference/builder/#copy) custom image (e.g. in a `Dockerfile`: `COPY /host/files /some/container/path`)
@@ -80,7 +80,7 @@ Let's break that command down into its individual pieces to see what's required
8080
-v /host/path/to/exports.txt:/etc/exports:ro \
8181
... \
8282
erichough/nfs-server
83-
83+
8484
1. provide each line of `/etc/exports` as an environment variable
8585

8686
The container will look for environment variables that start with `NFS_EXPORT_` and end with an integer. e.g. `NFS_EXPORT_0`, `NFS_EXPORT_1`, etc.
@@ -103,35 +103,35 @@ Let's break that command down into its individual pieces to see what's required
103103
1. **Use `--cap-add SYS_ADMIN` or `--privileged`**
104104

105105
As noted in the [requirements](#requirements), the container will need additional privileges. So your `run` command will need *either*:
106-
106+
107107
docker run --cap-add SYS_ADMIN ... erichough/nfs-server
108108

109109
or
110-
110+
111111
docker run --privileged ... erichough/nfs-server
112-
112+
113113
Not sure which to use? Go for `--cap-add SYS_ADMIN` as it's the lesser of two evils.
114114
115115
1. **Expose the server ports**
116116
117117
You'll need to open up at least one server port for your client connections. The ports listed in the examples below are the defaults used by this image and most can be [customized](doc/ports.md).
118118

119119
* If your clients connect via **NFSv4 only**, you can get by with just TCP port `2049`:
120-
120+
121121
docker run -p 2049:2049 ... erichough/nfs-server
122-
122+
123123
* If you'd like to support **NFSv3**, you'll need to expose a lot more ports:
124-
124+
125125
docker run \
126126
-p 2049:2049 -p 2049:2049/udp \
127127
-p 111:111 -p 111:111/udp \
128128
-p 32765:32765 -p 32765:32765/udp \
129129
-p 32767:32767 -p 32767:32767/udp \
130130
... \
131131
erichough/nfs-server
132-
132+
133133
If you pay close attention to each of the items in this section, the server should start quickly and be ready to accept your NFS clients.
134-
134+
135135
### Mounting filesystems from a client
136136

137137
# mount <container-IP>:/some/export /some/local/path
@@ -141,7 +141,7 @@ If you pay close attention to each of the items in this section, the server shou
141141
* [Kerberos security](doc/feature/kerberos.md)
142142
* [NFSv4 user ID mapping](doc/feature/nfs4-user-id-mapping.md)
143143
* [AppArmor integration](doc/feature/apparmor.md)
144-
144+
145145
## Advanced
146146

147147
* [customizing which ports are used](doc/advanced/ports.md)

entrypoint.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ assert_nfs_version() {
303303
echo "$requested_version" | grep -Eq '^3|4(\.[1-2])?$'
304304
on_failure bail "please set $ENV_VAR_NFS_VERSION to one of: 4.2, 4.1, 4, 3"
305305

306-
if [[ ( ! $(is_nfs3_enabled) ) && "$requested_version" = '3' ]]; then
306+
if [[ ( ! is_nfs3_enabled ) && "$requested_version" = '3' ]]; then
307307
bail 'you cannot simultaneously enable and disable NFS version 3'
308308
fi
309309
}
@@ -541,7 +541,7 @@ boot_main_nfsd() {
541541
read -r -a version_flags <<< "$(boot_helper_get_version_flags)"
542542
local -r threads=$(get_requested_count_nfsd_threads)
543543
local -r port=$(get_requested_port_nfsd)
544-
local -r args=('--debug' 8 '--port' "$port" "${version_flags[@]}" "$threads")
544+
local -r args=('--debug' 8 '--tcp' '--udp' '--port' "$port" "${version_flags[@]}" "$threads")
545545

546546
log "starting rpc.nfsd on port $port with $threads server thread(s)"
547547
$PATH_BIN_NFSD "${args[@]}"
@@ -588,7 +588,7 @@ summarize_nfs_versions() {
588588
;;
589589
esac
590590

591-
if [[ $(is_nfs3_enabled) && "$reqd_version" =~ ^4 ]]; then
591+
if [[ is_nfs3_enabled && "$reqd_version" =~ ^4 ]]; then
592592
versions="$versions, 3"
593593
fi
594594

0 commit comments

Comments
 (0)