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

Commit 23fe9af

Browse files
committed
Merge branch 'alpine' into develop
2 parents 09a73fc + 8e2ee49 commit 23fe9af

File tree

4 files changed

+27
-30
lines changed

4 files changed

+27
-30
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## [2.0.0] - not yet released
8+
9+
### Changed
10+
* Switch to Alpine Linux
11+
712
## [1.2.0] - 2018-09-26
813

914
### Added

Dockerfile

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
# Alpine can only be used if/when this bug is fixed: https://bugs.alpinelinux.org/issues/8470
2-
ARG BUILD_FROM=debian:stretch-slim
1+
ARG BUILD_FROM=alpine:latest
32

43
FROM $BUILD_FROM
54

6-
# https://github.com/ehough/docker-nfs-server/pull/3#issuecomment-387880692
7-
ARG DEBIAN_FRONTEND=noninteractive
8-
9-
# kmod is needed for lsmod, and libcap2-bin is needed for confirming Linux capabilities
10-
RUN apt-get update && \
11-
apt-get install -y --no-install-recommends nfs-kernel-server kmod libcap2-bin && \
12-
apt-get clean && \
13-
rm -rf /var/lib/apt/lists && \
14-
\
5+
RUN apk --update --no-cache add bash nfs-utils && \
6+
\
157
# remove the default config files
168
rm -v /etc/idmapd.conf /etc/exports
179

1810
# http://wiki.linux-nfs.org/wiki/index.php/Nfsv4_configuration
19-
RUN mkdir -p /var/lib/nfs/rpc_pipefs && \
20-
mkdir -p /var/lib/nfs/v4recovery && \
11+
RUN mkdir -p /var/lib/nfs/rpc_pipefs && \
12+
mkdir -p /var/lib/nfs/v4recovery && \
2113
echo "rpc_pipefs /var/lib/nfs/rpc_pipefs rpc_pipefs defaults 0 0" >> /etc/fstab && \
2214
echo "nfsd /proc/fs/nfsd nfsd defaults 0 0" >> /etc/fstab
2315

README.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ 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
1011
- clean teardown of services upon termination (no lingering `nfsd` processes on Docker host)
1112
- flexible construction of `/etc/exports`
@@ -39,7 +40,7 @@ This is the only containerized NFS server that offers **all** of the following f
3940
- `nfs`
4041
- `nfsd`
4142
- `rpcsec_gss_krb5` (*only if Kerberos is used*)
42-
43+
4344
Usually you can enable these modules with: `modprobe {nfs,nfsd,rpcsec_gss_krb5}`
4445
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.
4546
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.
@@ -56,13 +57,13 @@ Starting the `erichough/nfs-server` image will launch an NFS server. You'll need
5657
--cap-add SYS_ADMIN \
5758
-p 2049:2049 \
5859
erichough/nfs-server
59-
60+
6061
Let's break that command down into its individual pieces to see what's required for a successful server startup.
6162

6263
1. **Provide the files to be shared over NFS**
6364

6465
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:
65-
66+
6667
* [bind mounts](https://docs.docker.com/storage/bind-mounts/) (`-v /host/path/to/shared/files:/some/container/path`)
6768
* [volumes](https://docs.docker.com/storage/volumes/) (`-v some_volume:/some/container/path`)
6869
* files [baked into](https://docs.docker.com/engine/reference/builder/#copy) custom image (e.g. in a `Dockerfile`: `COPY /host/files /some/container/path`)
@@ -79,7 +80,7 @@ Let's break that command down into its individual pieces to see what's required
7980
-v /host/path/to/exports.txt:/etc/exports:ro \
8081
... \
8182
erichough/nfs-server
82-
83+
8384
1. provide each line of `/etc/exports` as an environment variable
8485

8586
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.
@@ -102,35 +103,35 @@ Let's break that command down into its individual pieces to see what's required
102103
1. **Use `--cap-add SYS_ADMIN` or `--privileged`**
103104

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

108109
or
109-
110+
110111
docker run --privileged ... erichough/nfs-server
111-
112+
112113
Not sure which to use? Go for `--cap-add SYS_ADMIN` as it's the lesser of two evils.
113114
114115
1. **Expose the server ports**
115116
116117
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).
117118

118119
* If your clients connect via **NFSv4 only**, you can get by with just TCP port `2049`:
119-
120+
120121
docker run -p 2049:2049 ... erichough/nfs-server
121-
122+
122123
* If you'd like to support **NFSv3**, you'll need to expose a lot more ports:
123-
124+
124125
docker run \
125126
-p 2049:2049 -p 2049:2049/udp \
126127
-p 111:111 -p 111:111/udp \
127128
-p 32765:32765 -p 32765:32765/udp \
128129
-p 32767:32767 -p 32767:32767/udp \
129130
... \
130131
erichough/nfs-server
131-
132+
132133
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.
133-
134+
134135
### Mounting filesystems from a client
135136

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

146147
* [customizing which ports are used](doc/advanced/ports.md)
@@ -153,7 +154,6 @@ Please [open an issue](https://github.com/ehough/docker-nfs-server/issues) if yo
153154
154155
## Remaining tasks
155156
156-
- switch to Alpine Linux once `nfs-utils` version 2.3.1-r4 (or higher) is released in a stable repo (maybe Alpine 3.9?). See [this bug](https://bugs.alpinelinux.org/issues/8470) for details
157157
- figure out why `rpc.nfsd` takes 5 minutes to startup/timeout unless `rpcbind` is running
158158
- add more examples, including Docker Compose
159159

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)