Self-Hosting Scanner

A vast majority of printers today also have scanning, copying and fax functions. Installing printer drivers is pretty straight forward on most operating systems. Installing programs that allow network scanning are often complex and need to be installed on every computer that requires this capability.

In this tutorial, we learn about a program called “scanservjs” and see that it can be used as a “scanning as a service” function on your network that is easily accessed from any web browser.

After the demo, I go through the steps necessary to install and configure scanservjs in docker. If you have a Docker host, you can easily add this application. If not, you can create a virtual machine or a LXD container to host your scanservjs instance.

I use a LXD container. My LXD container is exposed to my Main LAN through bridging which is frequently discussed on the channel. Assuming you have a bridge called “bridge0” and a LXD profile called “Bridged-MAIN”, here is the command I used to create a LXD container on my LXD host:

lxc launch ubuntu:22.04 Scan-test --profile default --profile Bridged-MAIN -c limits.memory=4096MB -c limits.cpu.allowance=20% -c boot.autostart=true -c security.privileged=true -c security.nesting=true

To enter the lxd host console:

lxc exec Scan-test bash

I created a user account, gave it sudo privilege, installed docker, docker-compose, and net-tools as in the video. You may need sudo before each of the following if you are not in the root account:

adduser scott
usermod -aG sudo scott
curl -sSL https://get.docker.com | sh
usermod -aG docker scott
apt install docker-compose
apt install net-tools
su - scott

On the docker host, add SANE support:

sudo apt install libsane

Scan for your scanners:

scanimage -L

Create a folder to install the application and move into it:

mkdir scanner
cd scanner

Edit the docker-compose file.

nano docker-compose.yml

Put the following contents into the docker-compose.yml file. Adjust the port 80, it it is in use on your docker host:

version: '3'
services:
  scanner:
    container_name: scanner
    privileged: true
    image: 'sbs20/scanservjs:latest'
    restart: unless-stopped
    ports:
      - '80:8080'
    volumes:
      - /var/run/dbus:/var/run/dbus
      - ./scannedfiles:/app/data/output
      - ./config:/app/config

Start the scanservjs application:

docker-compose up -d

Navigate to the ip address of your docker server in a browser using the port number if you changed the port 80 in my configuration file.