Sysctl: error setting key 'net.ipv4.conf.all.src_valid_mark': Read-only file system

Hello, a little late to the party but I’ve found a good fix.
include this line into the Dockerfile

RUN sed -i 's|\[\[ $proto == -4 \]\] && cmd sysctl -q net\.ipv4\.conf\.all\.src_valid_mark=1|[[ $proto == -4 ]] \&\& [[ $(sysctl -n net.ipv4.conf.all.src_valid_mark) != 1 ]] \&\& cmd sysctl -q net.ipv4.conf.all.src_valid_mark=1|' /usr/bin/wg-quick && \

And include the following option in docker compose (or the cli equivalent)

    sysctls:
      - net.ipv4.conf.all.src_valid_mark=1

This change makes wg-quick attempt to modify the value of net.ipv4.conf.all.src_valid_mark only when its not already set to 1. Docker compose sets it to 1 so the illegal operation never occurs.

I found this solution in the linuxserver/wireguard Dockerfile