A surveillance solution base on
Motion and Docker.
It's easy and ready to use. Just plug in a webcam and run dockmotion, then
videos and images will be saved once a motion is detected while a notification
e-mail including the recorded video and a preview image will be sent. On top of
that, the webcam can be accessed anytime via HTTP live streaming.
Clone this project then
cd into it:
git clone https://github.com/kfei/dockmotion cd dockmotion
Build for pull the image
Then build your own dockmotion Docker image:
docker build -t dockmotion .
Note that a pre-built image is also available:
docker pull kfei/dockmotion
Modify the sample
suit your webcam, e.g., videodevice, v4l2_palette, etc.
If using Gmail, change account and password settings in the
sample and save it as
Run the container with configs , e.g.,
docker run -it --device=/dev/video0 -p 8081:8081 \ -e TIMEZONE="Asia/Taipei" \ -e MAILTO="firstname.lastname@example.org" \ -v /data-store:/var/lib/motion \ -v /path/to/motion.conf:/etc/motion/motion.conf \ -v /path/to/ssmtp.conf:/etc/ssmtp/ssmtp.conf dockmotion
--deviceflag should be replaced by your webcam's device ID.
- Expose port 8081 so that you can watch the live streaming, e.g.,
Asia/Taipeiinstead of using UTC time.
- All alarm mails will be sent to the e-mail address provided by
- Mount a volume to
/var/lib/motionfor container since there might be lots
of images and videos produced by Motion.
There are some environment variables can be supplied at run time:
TIMEZONEis for correct time stamp when motion detected. Check
/usr/share/zoneinfoor see the full list of time
MAILTOto specify who will receive the alarm e-mails. Please make sure
you set up this correctly.
motion.conf can be overridden:
MOTION_PIXELSto specify the capture size of image, e.g.,
Note that the size must be supported by your webcam.
MOTION_TIMELAPSEfor the time-lapse mode, e.g.,
600,86400. Please see
below for further explanation.
The Time-lapse Mode
Using dockmotion to capture
time-lapse videos is
quite easy. The
MOTION_TIMELAPSE environment variable has two parts:
interval and duration, both in seconds. For instance, if a
MOTION_TIMELAPSE="600,86400" is supplied, Motion will capture images every 10
minutes within 24 hours. Note that in time-lapse mode, the motion detection
will be disabled.
An example run, for capturing one frame per hour within a week:
docker run -it --device=/dev/video0 -e MOTION_PIXELS="1280x720" \ -e MOTION_TIMELAPSE="3600,604800" \ -v /data-store:/var/lib/motion \ -v /path/to/motion.conf:/etc/motion/motion.conf \ dockmotion
Now a weekly time-lapse video will be in
A cool time-lapse:
(If you happen to know the author of this time-lapse, please let me know so I
may source them properly.)
There are many types of hook can be set in Motion. For instance,
dockmotion just provides an e-mail notification script as the
hook. Please dig into
motion.conf and define your own hooks.
HTTP Live Streaming