ninfs in Docker, just for fun (and a test)
1.2K
This is ninfs running in Docker!
I found out that FUSE can be used in containers if given the right permissions. For example:
docker run -it --rm \
--device /dev/fuse \
--cap-add SYS_ADMIN \
--security-opt apparmor:unconfined \
-v $PWD:/hostdir \
ianburgwin/ninfs
This would allow for creating mounts within the container.
On Linux only though, mounts can be shared back to the host:
docker run -it --rm \
--device /dev/fuse \
--cap-add SYS_ADMIN \
--security-opt apparmor:unconfined \
-v $PWD:/hostdir \
--mount type=bind,source=$PWD/abcdef,target=/abcdef,bind-propagation=rshared \
ianburgwin/ninfs
Then any mounts created in /abcdef inside the container would appear on the host.
Dockerfile (use --build-arg IMAGE=python:3.9-slim to build a slim variant)
ARG IMAGE=python:3.11
FROM $IMAGE
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
RUN set -eux \
&& apt-get update \
&& apt-get install -y --no-install-recommends fuse \
&& rm -rf /var/lib/apt/lists/*
RUN pip install --no-compile --no-cache-dir ninfs==2.0
CMD ["bash"]
Alpine variant
FROM python:3.11-alpine
ENV PYTHONUNBUFFERED=1
ENV PYTHONDONTWRITEBYTECODE=1
# ctypes.util.find_library does not find this for some reason
ENV FUSE_LIBRARY_PATH=libfuse.so.2
RUN set -eux \
&& apk add --no-cache zlib libjpeg-turbo fuse \
&& apk add --no-cache --virtual .build-deps gcc g++ musl-dev zlib-dev libjpeg-turbo-dev \
&& pip install ninfs==2.0 \
&& apk del --no-network .build-deps
CMD ["sh"]
Content type
Image
Digest
sha256:d0d1aca19…
Size
364.2 MB
Last updated
over 2 years ago
docker pull ianburgwin/ninfs