There are some people ask me how to make .NET 5 app to use remote nfs server with offical Microsoft aspnet image. I just demo how to mount nfs with image mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim
. You can make it work in K8S or any other orchestration platform. As long as you have nfs server first. Then have network access to nfs. Mount it and use it.
If you like my module, please buy me a coffee.
More and more tiny and useful GitHub action modules are on the way. Please donate to me. I accept a part-time job contract. if you need, please contact me: zhang_nan_163@163.com
go into the Nfs-Server folder. you would see a Dockerfile. Please build it as a local image.
docker build -t=yourname/nfs .
docker run -it --name nfs-server --privileged yourname/nfs
docker exec to container and make some modification.
echo "/exports *(rw,sync,no_subtree_check,fsid=0,no_root_squash)" >> /etc/exports
Then execute some commands:
# export file system from Linux
exportfs -r
# Start rpcbind service
service rpcbind start
# Start nfs service
service nfs-kernel-server start
go into ApplicationWithNfsClient folder. build image application image locally.
docker build -t webapp-with-nfs-client:latest .
run Container into your docker environment. keep the container in same network with nfs-server. replease place holder $NFS_SERVER_IP with real ip of nfs-server container.
docker run -it -e HOSTNAME=$NFS_SERVER_IP -e MOUNT_PATH=exports --name=webapp-with-nfs-client-1.3 --link nfs-server:nfs --privileged webapp-with-nfs-client:latest
PalPal: https://paypal.me/nzhang4