Using Synology Surveillance Station and Docker
-
Here are our official Docker image and instructions:
https://hub.docker.com/r/monoclecam/monocle-gateway
https://github.com/MonocleCam/monocle-gateway-dockerBasically 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.ymlversion: '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
-
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?
-
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:
I appreciate all the support and quick responses and I am excited to figure out this problem.
-
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:
And here is the running container instance:
The only way I managed to get this working was to use “macvlan” networking.
See:
- https://github.com/MonocleCam/monocle-gateway-docker/tree/master/examples
- https://docs.docker.com/network/macvlan/
Here on the container config you can see the associated network settings:
I’m also mounting a Shared Folder named “
monocle
” as a Docker volume for this container instance:The contents of the “
moncole
” Shared Folder only contain adocker-compose.yml
file and mymonocle-token
file.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 mymonocle
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 theifconfig
command. It’s far more common to useeth0
oreth1
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.
-
Here is where my docker compose file exists.
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.
-
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 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
-
The docker-compose will auto create the container and network stack, you should not have to manually create the macvlan network.
-
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. -
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. -
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.
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
Article:
https://monoclecam.com/monocle-gateway/install/synology -
I am also experiencing a similar issue, I set the docker instance up without any issues. However my echo show keeps saying “the camera isn’t responding”.
I have pasted a copy of my log to the link below, any assistance would be appreciated:
https://pastebin.com/MhCxf8bjHere is my camera feed history:
[ { "timestamp": "2019-12-04T17:59:41.976Z", "request": "InitializeCameraStreams", "response": [ { "uri": "rtsp://%USER%:%PWD%@192.168.0.40:554/Sms=2.unicast", "proxy": "rtsp://87939317-d807-451b-8275-24ce48c5e5b8.mproxy.io:443/STREAM:fabda600-c841-4e0e-ab69-aff675d202ff?session=8842c12c-3a24-4061-a604-85428d243a73", "resolution": { "width": "1920", "height": "1080" }, "authorizationType": "DIGEST", "videoCodec": "H264", "audioCodec": "AAC", "protocol": "RTSP" } ] }
And finally a screenshot of my cam setup in the Monocle portal:
Thanks,
Vel