Installing SmartSNO as Docker container

Installing – REQUIREMENTS

SmartSNO requirements:

IMPORTANT NOTES:

  • Ubuntu (and Debian) contain a much older KDE3/GNOME2 package called docker – make sure you are using the correct package

  • Docker version should be 1.3 or higher (in this version Docker introduced docker exec which is needed for installation purposes). You can check docker version with sudo docker --version. If your Linux distribution only provides an older version, you should install binary directly.

  • Some Linux distributions use SELinux by default (CentOS and possibly others). You should either disable SELinux or monitor its logs during this installation to spot (and solve) any SELinux related problems.

INSTALL

  1. Download SmartSNO Docker image and save it to the Linux host.

    Alternatively, you can download the file from command line:

    $ wget http://www.smartsno.com/?wpdmdl=310 -O smartsno.SMARTSNO_VERSION_HERE.tar.xz
    
  2. Check Docker version:

    $ sudo docker --version
    Docker version 1.3.1, build 4e9bbfa
    

    IMPORTANT:

    • make sure this is the correct Docker (the incorrect KDE3/GNOME2 package with the same name outputs copyright info (c) 2003 Ben Jansens)
    • Docker version should be 1.3 or higher (in this version Docker introduced docker exec which is needed for installation purposes).
  3. Check “transparent huge pages” memory management technique:

    $ cat /sys/kernel/mm/transparent_hugepage/enabled
    always [madvise] never
    

    If the selected option is [madvise] or [never], you can skip to the next step. If it is set to [always] however, you should either disable it or make it optional. For instructions see this page.

    IMPORTANT:
    After change you should reboot and re-check this setting to make sure that the change really persists across reboots.

  4. Load SmartSNO image to Docker:

    $ xz --decompress --stdout smartsno.SMARTSNO_VERSION_HERE.tar.xz | sudo docker load
    

    NOTE: This might take a few minutes, please wait.

    If you get an error “Cannot connect to the Docker daemon. Is ‘docker -d’ running on this host?” you should start docker service (sudo service docker start) and run the command again. You should also make sure that the service is started automatically after reboot (sudo update-rc.d docker defaults on Debian).

    You can check for success by running sudo docker images; there should be a new image present (named “smartsno”).

  5. Create shared directory:

    $ sudo mkdir -p /home/smartsno/shared/
    

    NOTE: This directory will be shared between host and Docker container and will contain all the data files (database, relevant logs, certificates and similar). You should never alter the contents of this directory while the container is running. Feel free to use another directory path if you wish, but make sure you use it when you run the container. The owner of this directory should be root.

  6. Run SmartSNO container:

    This command assumes that you wish to publish all exposed ports to the host. Depending on your intended use you might wish to omit some of the ports or publish them on different host ports. Exposed ports are: 69/udp (tftp), 161/udp (snmp v2), 162/udp (snmptrap), 443 (https), 514 and 514/udp (syslog).

    $ sudo docker run --restart=always -d --net=host -v /home/smartsno/shared/:/shared/ \
      --name=smartsnoc smartsno:SMARTSNO_VERSION_HERE
    

    NOTE: The command will fail if host port is already used by another service (in that case you will get an error message ending with “bind: address already in use”). To fix the problem, either publish the oppending port to another host port (-p 4443:443 will publish to host port *4443) or disable offending service (you can get the list with sudo netstat -tupln). Upon fixing the failure reason run sudo docker rm smartsnoc (to remove the non-running container with this name) and run the command again.

  7. Check container status:

    $ sudo docker ps
    

    NOTE: Status for container smartsnoc should be “Up”.

  8. Initialize shared directory:

    $ sudo docker exec -i -t smartsnoc /home/sc/smartsno/init.sh
    

    NOTE: This command initializes shared directory (initializes database, creates self-signed https certificates, creates SSH key pair) and automatically runs SmartSNO upon successful completion.

    If you wish to replace generated https and ssh keys/certificates with your own, you should stop container (sudo docker stop smartsno), replace them and run container again (sudo docker start smartsnoc).

  9. Finally, navigate your browser of choice to https://<your host ip>/ (CAREFUL: this is https, not http). You will probably need to confirm security exception (unless you have replaced self-signed https certificates with your own).

Enjoy! 🙂