-
Notifications
You must be signed in to change notification settings - Fork 662
Install In Docker
There are three options to run motionEye in Docker.
Method 1 (easiest) is to use the automatically built and published Docker images from Docker Hub. Unfortunately the automatic image creation is not yet available for stable releases of motionEye, but it will be available with the next release. The currently existing images are built from the actual development in the dev
branch. Images for x86 and Raspberry Pi architectures are available.
Method 2 is a bit more complex creating the image on your own.
Method 3 is just a bit more complex than method 2, but gives you a container with Debian 10, motion 4.3.2-1, and the latest development build of motionEye (0.42.1 with the Privacy Mask enhancement, and others. Currently Method 3 is only working for amd64, but hopefully will be available for Debian 11, and armhf soon.
The Dockerfile
for the automatically built image and a sample docker-compose.yml
are both in the /extra
directory of the project (https://github.com/ccrisan/motioneye/tree/dev/extra) stored. Furthermore there is a Dockerfile.armv7-armhf
for a Docker image for the Raspberry Pi platform.
If you like to contribute or testing motioneye
project, you can use the docker container.
The automatically built images are available on Docker Hub https://hub.docker.com/r/ccrisan/motioneye/. The actual usable tags are master-amd64
and master-armhf
. All other tags are from temporary feature branches and should not be used. Tags for stable releases of motionEye currently do not exist. They will be available with the next release.
Download the image with one of the following commands according to your underlying architecture. The image tagged with master-amd64
is built for x86 architecture using the current development branch of motionEye. The image tagged with master-armhf
is built for Raspberry Pi architecture.
docker pull ccrisan/motioneye:master-amd64
docker pull ccrisan/motioneye:master-armhf
Use the following command to start motionEye inside a Docker container. You don't need to download the images first. If you just fire the start command, the images are downloaded automatically, if they do not exist locally.
docker run --name="motioneye" \
-p 8765:8765 \
--hostname="motioneye" \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/motioneye:/etc/motioneye \
-v /var/lib/motioneye:/var/lib/motioneye \
--restart="always" \
--detach=true \
ccrisan/motioneye:master-amd64
Change the last line to: ccrisan/motioneye:master-armhf if running on any ARM Processor based system.
Note: If running with docker-ce, you may get: "WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm/v7) and no specific platform was requested" You may safely ignore this message, the WebGUI will be available at http://IP_of_DOCKER_HOST:8765.
Add additional port mappings with the -p
parameter if you want to use the streaming feature of motion: -p 8765:8765 -p 8081:8081
; for cameras added, numbering of ports used for streaming starts from 8081 (second camera will use port 8082, etc). Ports used for streaming can be later changed in motionEye (Video Streaming -> Streaming Port) but should always match the ones that are being exposed from Docker.
If using additional services that make use of ports in the 808x range, then default mapping can be edited to avoid conflicting by mapping higher range port numbers that are not in use by other services (i.e., -p 8765:8765 -p 58081:8081 -p 58082:8082
)
Change the two bind paths /etc/motioneye
and /var/lib/motioneye
according to your needs. The first contains the configuration files for motionEye and the second will be used as file storage for still images and movies. The bound file /etc/localtime
is necessary for a proper timezone configuration inside the container using the timezone of the host.
To forward a video device of your host use an additional parameter like the following
--device=/dev/video0
Second and third options to get the motionEye Docker image start here to build it on your own. The actually good maintained version of Docker images currently only exist for the dev
branch.
-
Clone your fork or official
motioneye
projectgit clone -b dev https://github.com/ccrisan/motioneye.git
-
Build your motionEye Docker image from the
Dockerfile
.
enter project folder
cd motioneye
If you want to build the method 3 container, you need to replace the extra/Dockerfile
with the contents at the end of this page.
You would then continue with the instructions here.
If you would like build docker image from official project docker build --build-arg VCS_REF=$(git rev-parse HEAD) --build-arg BUILD_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ") \ -t ccrisan/motioneye:master-amd64 -f extra/Dockerfile .
If you want to build the image for Raspberry Pi use the following commands: (DO NOT use the amd64 replacement Dockerfile!)
cd motioneye
# Run this command only if you want to build the image for Raspberry Pi on a x86 architecture.
docker run --rm --privileged multiarch/qemu-user-static:register --reset
docker build --build-arg VCS_REF=$(git rev-parse HEAD) --build-arg BUILD_DATE=$(date +"%Y-%m-%dT%H:%M:%SZ") -t ccrisan/motioneye:master-armhf -f extra/Dockerfile.armv7-armhf .
The additional command for building the image on x86 architectures is necessary to register a qemu emulation for the Raspberry Pi platform in your kernel. Do not use the command if your building host is already running on Raspberry Pi. Architecture emulation in software is very slow!
Note: If /etc/motioneye/motioneye.conf does not exist, it is copied from /usr/share/motioneye/extra/motioneye.conf.sample (Not overwrite the volume)
-
Have a cup of coffee while the image builds :)
-
Either start a container using
docker run
or use the provided sampledocker-compose.yml
together withdocker-compose
.
Using the docker run
command is described under the first chapter describing how to run the ready to use images.
Edit docker-compose.yml
and modify the timezone to your own (A list is available at http://php.net/manual/en/timezones.php).
Also edit the two mount points to a directory in your system. Save the file, and then run:
docker-compose -f docker-compose.yml -p motioneye up -d
If you would contribute or test your development, update the code, and rebuild the docker container, see the step 2.
New contents for the extra/Dockerfile for amd64:
FROM debian:buster-slim LABEL maintainer="Marcus Klein [email protected]"
ARG BUILD_DATE
ARG VCS_REF
LABEL org.label-schema.build-date=$BUILD_DATE
org.label-schema.docker.dockerfile="extra/Dockerfile"
org.label-schema.license="GPLv3"
org.label-schema.name="motioneye"
org.label-schema.url="https://github.com/ccrisan/motioneye/wiki"
org.label-schema.vcs-ref=$VCS_REF
org.label-schema.vcs-type="Git"
org.label-schema.vcs-url="https://github.com/ccrisan/motioneye.git"
ARG RUN_UID=0 ARG RUN_GID=0
COPY . /tmp/motioneye ADD https://github.com/Motion-Project/motion/releases/download/release-4.3.2/buster_motion_4.3.2-1_amd64.deb ./motion.deb
RUN echo "deb http://snapshot.debian.org/archive/debian/$(date +%Y%m%d) buster contrib non-free" >>/etc/apt/sources.list &&
apt-get update &&
DEBIAN_FRONTEND="noninteractive" apt-get -t buster --yes --option Dpkg::Options::="--force-confnew" --no-install-recommends install
curl
ffmpeg
libmicrohttpd12
libpq5
lsb-release
mosquitto-clients
python-jinja2
python-pil
python-pip
python-pip-whl
python-pycurl
python-setuptools
python-tornado
python-tz
python-wheel
v4l-utils
./motion.deb
default-libmysqlclient-dev &&
# Change uid/gid of user/group motion to match our desired IDs. This will
# make it easier to use execute motion as our desired user later.
sed -i -e "s/^(motion:[^:]):[0-9]:[0-9]:(.)/\1:${RUN_UID}:${RUN_GID}:\2/" /etc/passwd &&
sed -i -e "s/^(motion:[^:]):[0-9]:(.)/\1:${RUN_GID}:\2/" /etc/group &&
pip install /tmp/motioneye &&
# Cleanup
rm -rf /tmp/motioneye &&
apt-get purge --yes python-setuptools python-wheel &&
apt-get autoremove --yes &&
apt-get --yes clean && rm -rf /var/lib/apt/lists/ && rm -f /var/cache/apt/*.bin
ADD extra/motioneye.conf.sample /usr/share/motioneye/extra/
VOLUME /etc/motioneye
VOLUME /var/lib/motioneye
CMD test -e /etc/motioneye/motioneye.conf ||
cp /usr/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf ;
# We need to chown at startup time since volumes are mounted as root. This is fugly.
chown motion:motion /var/run /var/log /etc/motioneye /var/lib/motioneye /usr/share/motioneye/extra ;
su -g motion motion -s /bin/bash -c "/usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf"
EXPOSE 8765
home | installation | faq