I want to run tail -f /var/log/xxx.log
file from existing container, where /var/log/xxx.log
is a log file inside host.
From docs and with google search, I have found that this is possible with bind mount.
But I couldn't run tail -f /var/log/xxx.log
. Any advice or proper document about bind mount would be appreciated.
Thanks in advance
You can import the log directory as a volume when you run your Docker image, and run your command through Docker that way. An example could be running:
$ docker run -v /path/to/log:/working your_image tail -f /working/xxx.log
, where you have to replace
/path/to/log
with/var/log
, andyour_image
with the name of your image.The
-v
command requires the path to your folder (within the Host machine) and the location where the path should be mounted to (withing the container). The two locations are place before and after a colon.In the case above, the path
/path/to/log
is the path to your log folder on your machine, and that location it is mounted to/working
within the container. Finally, when running thetail
command, you access your log file through the/working
directory, which is within the container.More information about all this can be found here!