Introduction
Navidrome is a free and open source software that lets you access your music collection from anywhere, through a web UI and various mobile apps. It supports large libraries, fast streaming, file conversion and modern features.
The Docker Compose File
---
version: "3.8"
services:
navidrome:
image: deluan/navidrome:latest
container_name: navidrome
hostname: navidrome
restart: unless-stopped
network_mode: host
security_opt:
- no-new-privileges:true
user: 1000:1000
environment:
- TZ=Europe/Stockholm
- ND_SCANSCHEDULE=1h
- ND_LOGLEVEL=info
- ND_SESSIONTIMEOUT=24h
ports:
- 4533:4533
volumes:
- /opt/navidrom/config:/data
- /data/media/music:/music:ro
labels:
- com.centurylinklabs.watchtower.enable=true
docker-compose.yml
This Docker Compose file defines a single service named “navidrome”. The service is built from the “deluan/navidrome:latest” Docker image, which is the latest version available. The container name is set to “navidrome” as well.
The “restart” section ensures that the container will always be restarted if it exits (unless manually stopped). This is useful for ensuring that the service is always available, especially if it crashes or is shut down unexpectedly.
The “security_opt” section prevents your container processes from gaining additional privileges. This is an important security consideration.
The “ports” section maps port 4533 on the host machine to port 4533 in the container. This allows us to access the navidrome web interface from our local machine. By default, navidrome runs on port 4533, but you can change it if necessary.
The “volumes” section maps the “/data” directory inside the container to a local directory on the host machine. This allows us to persist data across container restarts. navidrome stores all its configuration and monitoring data in this directory, so it’s important to keep it intact. The "/music" directory is also mapped in read-only mode to the local music directory.
The "labels" section allows the Watchtower service to keep this container update automatically.
Running Navidrome with Docker Compose
To run navidrome with Docker Compose, first, make sure you have Docker and Docker Compose installed on your machine. Then, create a new directory for your project and save the above Docker Compose file as “docker-compose.yml” in that directory.
Next, run the following command from the same directory:
docker compose up -d
This command will start the Navidrome container in the background and detach from it. You can then access the navidrome web interface by going to http://localhost:4533 in your web browser.
Conclusion
In this article, we explored how to set up and run the Navidrome software using Docker Compose. We looked at the different sections of the Docker Compose file and explained how they work together to create a functional navidrome service. By running Navidrome with Docker Compose, you can easily deploy and manage the tool on your own server, without having to worry about dependencies or configuration.
