Thursday, September 8, 2022

Editing config files for docker containers with vim

Hi,

I'm maintaining set of docker containers. We use convention that
every config file for a container is in /srv/<container>/ subdirectory.
E.g. /srv/<container>/etc/cron.daily/logrotate.
We use vim to maintain config files and we like feature/shortcut 'gf'
which opens file on cursor. E.g. logrotate file contains:

#!/bin/sh

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
/usr/bin/logger -t logrotate "ALERT exited abnormally with
[$EXITVALUE]"
fi
exit $EXITVALUE

therefore when I use 'gf' on /etc/logrotate.conf, file should be opened.

The issue is that path is correct when container is running, but when
I'm editing it from the host, it should be
/srv/<container>/etc/logrotate.conf.
Therefore I'm looking for vim setting or extension of vim which will
add requested prefix to file name when I'm opening it.

Any advice is welcome.

Best regards,

Jirka Novak

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/83a3be50-3ac6-abfb-9491-8c9e6524aca0%40netsystem.cz.

No comments:

Post a Comment