Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Ensure a hosts entry for a docker container running as a systemd service.
- I'm going to hell :/
- if you're *not* running in a user context, you don't need the container priv esc to overwrite the hosts file.
- ExecStartPost=/bin/bash -c "( flock 9 || exit 1;until [ \"\$(docker inspect -f {{.State.Running}} %n )\" == \"true\" ]; do sleep 0.1; done; grep -v '%n' /etc/hosts > /tmp/tmphosts && echo \"\$( docker inspect -f '{{.NetworkSettings.IPAddress }}' %n ) %n #autogenerated\" >> /tmp/tmphosts && docker run --rm -v/tmp/tmphosts:/tmp/tmphosts -v/etc/hosts:/etc/hosts alpine sh -c 'cat /tmp/tmphosts > /etc/hosts' ) 9> /tmp/tmphosts.lock"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement