Share files over the network: smoothly and gracefully

Share files between local devices
Share files between local devices

You probably know the situation: You are sitting at a friend’s and/or client’s place and want to share some pictures or an installer. For small files, an e-mail may be justified, but even a few MB may take ages, if the mail server doesn’t refuse larger files at all. Those, who understand the path that an e-mail needs to follow, can certainly understand that this is an extremely inelegant solution.

An alternative is to copy the files to a USB stick, but who always has a stick with them? And then the stick may be formatted in a way that it is not readable on the target system…
Those solutions are rather like this… nineties… ;-)

It is much more elegant to start a webserver on your own laptop, which serves the files in the local network!

Installing and configuring a whole web server for such a nonsense? How fast should the operating system age??

Yes, exactly! But install it virtualised in a container, instead of natively on the laptop. Nowadays, every good IT professional has Docker or something similar on his laptop anyway, and an image from a web server is usually already downloaded (otherwise Docker loads it relatively quickly on first use).
This way, you can share any file very quickly and elegantly. For example, I prefer to use the Nginx web server (but of course you can also use the httpd of Apache, lighttpd and others). If I want to share the file /path/to/ I just call:

docker run --rm -v /path/to/ -p 80:80 nginx

Thada…! Now can be downloaded from the laptop as http://IP.OF.THE.LAPTOP/ If the laptop received a DNS name in the network it is even more comfortable.

Anyway, this is really amazingly fast and reliable in almost every network. Much faster than sending it to your mail server, which then forwards it to the next mail server, etc…
The only requirement is that the computers must be able to communicate with each other in the local network (a few networks prohibit client-to-client communications). Only files mounted into the container are shared. The webserver will not be able to see any other files on your laptop and, thus, will not accidentally share something else!
However, don’t forget to stop the container at the end of the session to avoid accidentally “sharing” files in the next network and/or accumulating sharing web servers ;-)
Thanks to the --rm flag everything is tidy again afterwards. The system stays young!

More alternatives

  • If both people use the same chat system, you can also quickly transfer files via Matrix or Threema or something like that.
  • If you have a cloud (Nextcloud, Dropbox, Onedrive, Google Drive, Mega, etc), you can of course also share files conveniently via it. There are also a number of providers on the net where you can upload and share files without registration.

However, these approaches mean that the files have to leave the local infrastructure. This is not very nice in terms of security and privacy and tends to take longer.
The solution with the local web server in a docker container would certainly be preferable.

Translated with (free version)