Using Synology Surveillance Station and Docker



  • I have set up my cameras with my Monocle and Alexa account using a previous Synology guide. I am having issues with getting Alexa to pull the streams, instead of her saying that the device is not responding.

    I have installed Monocle-Gateway container on my Synology Docker and continue to get this same error in the logs:

    DOCKER ERR.png

    I have added the monocle.token API file to multiple places on the Synology linux system as well as directly in the same file at the “monocle-gateway” and “monocle-proxy” files.

    I have 2 Amcrest cameras that are currently on the NAS network, and neither of them will show on my Alexa Spot, Show, or Show 5.

    Any suggestions on getting Docker on Synology to work with monocle-gateway?

    Here are a few directories I used:

    volume4/@docker/btrfs/subvolumes/cab8b1faf476e6d419cdd62c4bcd6b3ee949f461ef6a349963ab14e8223b250e/usr/local/bin/monocle.token

    ~/monocle.token

    /usr/bin/monocle.token

    I also am unsure if I have to change the volume or container environment settings from within Docker.



  • @burkminipup

    Here are our official Docker image and instructions:

    https://hub.docker.com/r/monoclecam/monocle-gateway
    https://github.com/MonocleCam/monocle-gateway-docker

    Basically the container expects to find the monocle.token file in the path: /etc/monocle
    (This is the default path for all Monocle Gateway linux-based distributions)

    In this example Docker compose file, you can see that we simply mount a volume to that path from the container host.
    https://github.com/MonocleCam/monocle-gateway-docker/blob/master/examples/host-network/docker-compose.yml

    version: '3.4'
    
    services:
      monocle-gateway:
        container_name: monocle-gateway
        hostname: monocle-gateway
        image: monoclecam/monocle-gateway
        restart: always
        volumes:
          - /etc/monocle:/etc/monocle
        network_mode: host
    

    Also, it’s important to read thru the networking consideration and choose the best option for your setup. Start with “host mode” networking if you are able to.

    Thanks, Robert



  • @Monocle

    I will look back through those pages, but I do not think the container is accessing the directories because the way that Synology sandboxes the installed packages. I will try other directories.

    If I am not mistaken, Synology uses port 443 for NGINX for remote access? Will this be a problem for host mode?

    Where do I add the networking files to change the network mode?



  • @burkminipup

    You are right, I overlooked that you mentioned trying to get it running on a Synology NAS. Host mode will not work.

    As for the monocle.token file …
    You will have to mount another path from a shared volume on the NAS to your container, but to the container it should see it as /etc/monocle. Or for testing, you can just open a shell into the running instance and create this path and create this file inside the container. This is not a long term solution but might help you get up and running to start testing the gateway with your camera.



  • I was able to find the correct ~etc/monocle/ directory within the container to get the gateway to actually run. I have the container bridged, but as mentioned before, I believe it is not working because port 443 is already in use.
    Here are my logs and network settings:

    Screen Shot 2019-08-06 at 12.33.58 PM.png
    Screen Shot 2019-08-06 at 12.33.47 PM.png

    Screen Shot 2019-08-06 at 12.34.57 PM.png
    Screen Shot 2019-08-06 at 12.35.07 PM.png

    I appreciate all the support and quick responses and I am excited to figure out this problem.



  • @burkminipup

    This post might be a bit long, but I want to include example screenshots of it all set up and working on my Synology NAS.
    Its been a while since I originally set this up, so some of the details are a bit fuzzy.

    Here you can see I have a copy of the latest “monocle-gateway” container from DockerHub:
    985cbe4a-f8d2-4e83-936c-40e270a2ddf5-image.png

    And here is the running container instance:
    d399daed-7daa-4cc6-b10f-4e1fa3db5300-image.png

    The only way I managed to get this working was to use “macvlan” networking.

    ab7543d9-05eb-49a7-b201-f6bd5654d5bf-image.png

    See:

    Here on the container config you can see the associated network settings:

    5561c480-b74a-4479-b8ab-31c8661078f3-image.png

    I’m also mounting a Shared Folder named “monocle” as a Docker volume for this container instance:

    a59849b9-96b3-471d-b1b7-971d91fddca5-image.png

    The contents of the “moncoleShared Folder only contain a docker-compose.yml file and my monocle-token file.

    254453d4-e1bb-46b5-849a-615f5909f530-image.png

    There is no way using the Synology GUI to create a Docker container with macvlan, so I SSH into the Synology NAS and use the docker command line to create a container with the docker-compose.yml file.

    Here are the contents of my docker-compose.yml file.

    version: '2'
    
    services:
    
      monocle-gateway:
        container_name: monocle-gateway
        hostname: monocle-gateway
        image: monoclecam/monocle-gateway
        restart: always
        volumes:
          - /volume1/monocle:/etc/monocle
        networks:
          monocle-gateway-network:
            ipv4_address: 10.1.1.198
           
    networks:
    
      monocle-gateway-network:
        driver: macvlan
        driver_opts:
          parent: ovs_bond0
        ipam:
          config:
            - subnet: 10.1.0.0/16
              gateway: 10.1.1.1
    

    You will need to modify this for your system!

    • In my case, my network is 10.1.X.X.
    • The /volume1/monocle:/etc/monocle is the path to my monocle shared folder located on Volume 1 of my NAS.
    • ipv4_address is the STATIC IP address I want to manually assign to the gateway. (Note: this address should be reserved or outside the DHCP range of your network router.)
    • driver_opts>parent: is the IP interface that my NAS uses to connect to the local network. In my case, it’s a bonded network interface because I’m using Link Aggregation (You can get the named interfaces using the ifconfig command. It’s far more common to use eth0 or eth1 if you are just using a standard network connection on the NAS.)
    • ipam>config>subnet is the default subnet for my local network.
    • ipam>config>gateway is the IP address of the router for my local network.

    I hope this helps!

    Thanks, Robert



  • That information is very helpful, but I have been messing around trying to create the macvlan network driver in the docker CLI, but I don’t have the process correct to build the container.
    I tried the docker network create commands, but it does not add the driver. Is it possible to just edit the .yml file and upload it to the NAS? I can do this, I just do not know where the file would be located.

    Could you do a “find . -name docker-compose.yml” to show the correct directory?

    This is my configuration:

    version: '2'
    
    services:
    
      monocle-gateway:
        container_name: monocle-gateway
        hostname: monocle-gateway
        image: monoclecam/monocle-gateway
        restart: always
        volumes:
          - /etc/monocle:/etc/monocle:/docker/etc/monocle
        networks:
          monocle-gateway-network:
            ipv4_address: 192.168.0.229
           
    networks:
    
      monocle-gateway-network:
        driver: macvlan
        driver_opts:
          parent: bond0
        ipam:
          config:
            - subnet: 192.168.0.0/24
              gateway: 192.168.0.1
    

    Also, I mounted a similar share to the monocle container, but it is using the token from this file path:

    ./volume4/@docker/btrfs/subvolumes/cab8b1faf476e6d419cdd62c4bcd6b3ee949f461ef6a349963ab14e8223b250e/etc/monocle/monocle.token

    Hopefully I can figure this all out. I would also be interested if you have a contribution page to help development.



  • @burkminipup

    Here is where my docker compose file exists.

    04578304-79f2-415f-b719-917d5397ca73-image.png

    Its in the same “monocle” shared folder located on “Volume 1” as my monocle.token file.



  • After about the 5th time, I got it created with this syntax:

    docker network create -d macvlan --subnet=192.168.0.0/24 --gateway=192.168.0.1 -o parent=bond0 monocle-network

    Now do I need to upload the .yml file separately? I have already assigned it through GUI.

    Monocle-Network.PNG



  • @Monocle

    I could not get Monocle to use that directory for my token. I will just put the .yml in the same directory that my token is currently working in.



  • @burkminipup

    I just copied the docker-compose.yml file to my “monocle” shared folder, then from the command line I used the docker-compose tool with the -up argument. Something like this:

    docker-compose up -d ./docker-compose.yml
    

    see: https://docs.docker.com/compose/reference/up/



  • @burkminipup

    The docker-compose will auto create the container and network stack, you should not have to manually create the macvlan network.



  • @burkminipup

    I’m not sure this is correct in your docker-compose yml.

        volumes:
              - /etc/monocle:/etc/monocle:/docker/etc/monocle
    

    Mine is:

    • /volume1/monocle:/etc/monocle

    This means /volume1/monocle on the NAS gets mounted as /etc/monocle inside the running container.
    This allows us to store the monocle.token file and any other config outside of the container and allow you to stop and start/destroy/rebuild your container without losing any config.



  • @burkminipup

    FYI, I am logged in via SSH using an “admin” level access account on the NAS.



  • @burkminipup said in Using Synology Surveillance Station and Docker:

    I could not get Monocle to use that directory for my token. I will just put the .yml in the same directory that my token is currently working in.

    I don’t think it matters where “docker-compose.yml” exists. Monocle-Gateway does not use this file. So no need for it inside the container.
    You can put it anywhere on your NAS so long as you can access it via the SSH terminal to your NAS. Then just use the docker-compose executable to load this docker-compose.yml config file. This will make Docker build the container and networking stack.



  • @Monocle

    When you said:

    • ipv4_address is the STATIC IP address I want to manually assign to the gateway. (Note: this address should be reserved or outside the DHCP range of your network router.)

    Are you creating an IP address for the gateway? I have my IP address outside my DHCP pool, but I want to confirm that this is not supposed to be the NAS IP address. I have the gateway of the macvlan set to my router.

    Another thing, would port-forwarding help allow my streams to make a connection? I can get the Monocle RTSP server running, but have not had luck with the connection. Also, after the connection fails, then Monocle goes into a disconnect loop.

    Monocle-Network Disconnect.JPG

    I am going to also try with a non Synology RTSP setup when I get home.

    Thanks again.



  • @burkminipup said in Using Synology Surveillance Station and Docker:

    @Monocle
    When you said:

    ipv4_address is the STATIC IP address I want to manually assign to the gateway. (Note: this address should be reserved or outside the DHCP range of your network router.)

    Are you creating an IP addres

    It’s an IP address that gets assigned to the Monocle Gateway instance running as a Docker container. Its an IP address that is valid on your existing private LAN, but one that is outside your DHCP range so that you don’t end up with two nodes on the network competing for the same address.

    The errors you posted are acting like the Monocle Gateway cannot access the Internet or possibly does not have a valid DNS server to resolve the hostname for the Monocle API server.

    I don’t think any port forwarding is required.

    I am going to also try with a non Synology RTSP setup when I get home.

    I agree, lets get it working here first before complicating the setup with a Docker container running on the Synology.

    Thanks, Robert



  • How To Install Monocle Gateway on a Synology NAS as a Docker Container

    How To Install Monocle Gateway on a Synology NAS as a Docker Container
    Article:
    https://monoclecam.com/monocle-gateway/install/synology


Log in to reply