usher
usher copied to clipboard
Docker image uses an old version of `sed` that doesn't work properly within Docker
The dockerfile pulls ubuntu:20.04 as its base image, which includes 4.7 of sed
. This version of sed
has filesystem issues breaks thing when it is running in a Docker image. If this version of sed
is run on a file that is mounted to the Docker image, it does not work, whether or not sed
is run with -i
or if you chmod 777
the workdir, and even though the container by default runs as root. Note that this does not happen with all versions of Docker -- this is a Docker Desktop thing, but Docker Desktop is what Docker tends to push these days, so compatibility with it is important.
Ideally, a newer base image should be used, or sed should be manually updated to 4.8 somewhere in the Dockerfile.
More information
https://discourse.pi-hole.net/t/sed-couldnt-open-temporary-file-etc-pihole-sed/65159/4
To replicate
This is a known issue with sed and may not need to be replicated, but here's how I found it:
- Have a MacOS running Docker Desktop
- Build the image locally via
docker build --no-cache -t usher install/
- Bind the host's workdir, which contains some_file.txt, to
/data
within the Docker container and enter the container viadocker run -v .:/HOME/usher/data -it [whatever-id-the-image-ends-up-with]
-
cd
into/data
and attempt tosed -i 's/,/\n/g' some_file.txt
or sed 's/,/\n/g' some_file.txt > brand_new_temp_file.txt - Get permissions error
side note (bonus bug?)
There's a rendering error on GitHub with the second sed command. In case it shows up funky, this is what's intended:
Not:
Either way, the point is, this isn't solvable by just not using sed -i
.