Nginx FTP server with Docker and multiple volume

Here, we are creating ftp server with nginx docker image and mounting multiple directory as volume, so that we can access those file over the network.
sudo docker run -d --name nginx-ftp --restart=unless-stopped -p 8080:80 -v /home/user/movie/:/usr/share/nginx/html:ro -v /home/user/more-movie/:/usr/share/nginx/html/more-movie:ro nginx
We can check, if the server is up and running by visiting localhost:8080
. We can see restricted page as nginx does not allow file access by default. So need to configure nginx to allow it. Here is the content of configuration file default.conf
.
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
autoindex on;
autoindex_exact_size off; # Optional: Show file sizes in a human-readable format
autoindex_localtime on; # Optional: Show timestamps in local time
disable_symlinks off; # Allow following symlinks
}
}
Now lets copy the config file into the running container nginx-ftp
.
sudo docker cp /home/user/default.conf nginx-ftp:/etc/nginx/conf.d/default.conf
Now we have to restart the container to apply the config.
sudo docker restart nginx-ftp
If we revisit the link localhost:8080
, we can see all the file and directory we mounted as movie
volume. But the contents of more-movie
volume is not accessible. We can make it visible by symlink that directory.
ln -s /home/user/movie/ /home/user/more-movie/
After this symlink creation, we can also access contents of more-movie
directory.
Thank you :-)
Subscribe to my newsletter
Read articles from Md. Kaiyom directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Md. Kaiyom
Md. Kaiyom
To live in hearts we leave behind is not to die