I have deployed n8n using Docker on Ubuntu 22.04 and want to use yt-dlp to download videos. I need to change the default download path from /home/node/ to /root/videos on the host so that I can automatically delete these mp3 or mp4 files later.
My questions are:
- How do I modify the output path in the yt-dlp command and Docker setup?
- The container lacks sudo permissions under
/home/node/—what is the proper way to handle this?
- How can I set up regular cleanup for both n8n logs and downloaded video files?
Below is an example of my current configuration and the changes I am considering:
Example of the yt-dlp command (original):
yt-dlp -o "/home/node/%(title)s.%(ext)s" <video-url>
Modified yt-dlp command for the desired path:
yt-dlp -o "/root/videos/%(title)s.%(ext)s" <video-url>
Docker Compose volume mount for exposing /root/videos on the host:
services:
n8n:
image: docker.n8n.io/n8nio/n8n
ports:
- "127.0.0.1:5678:5678"
environment:
# your other variables...
volumes:
- n8n_data:/home/node/.n8n
- /root/videos:/root/videos # mount host’s /root/videos folder
To address permission issues, one option is to adjust the permissions on the host directory:
sudo chown -R 1000:1000 /root/videos
For log rotation in Docker, you might add the following to your Compose file:
services:
n8n:
image: docker.n8n.io/n8nio/n8n
ports:
- "127.0.0.1:5678:5678"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
# volumes and environment...
Additionally, to regularly clear downloaded files (e.g., deleting files older than 7 days), you can set up a cron job on the host:
0 3 * * * find /root/videos -type f -mtime +7 -delete
Please let me know if there are any suggestions or corrections to achieve this setup. Thank you and have a good day!