Skip to content

Install In Docker

Marcus Klein edited this page Jan 14, 2018 · 14 revisions

There are two options to run motionEye in Docker. The easiest method 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. A more complex method is to create the image on your own.

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.

Image from Docker Hub

The automatically built images are available on Docker Hub https://hub.docker.com/r/ccrisan/motioneye/. The actual usable tags are dev-amd64 and dev-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 dev-amd64 is built for x86 architecture using the current development branch of motionEye. The image tagged with dev-armhf is built for Raspberry Pi architecture.

docker pull ccrisan/motioneye:dev-amd64
docker pull ccrisan/motioneye:dev-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" \
    ccrisan/motioneye:dev-amd64

Add additional port mappings with the -p parameter if you want to use the streaming feature of motion. 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

Build instructions

Second option to get the motionEye Docker image is to built it on your own. The actually good maintained version of Docker images currently only exist for the dev branch.

  1. Clone your fork or official motioneye project

    git clone -b dev https://github.com/ccrisan/motioneye.git

  2. Build your motionEye Docker image from the Dockerfile.

    enter project folder

    cd motioneye

    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:dev-amd64 -f extra/Dockerfile .

If you want to build the image for Raspberry Pi use the following commands:

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:dev-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)

  1. Have a cup of coffee while the image builds :)

  2. Either start a container using docker run or use the provided sample docker-compose.yml together with docker-compose.

Using the docker run command is described under the first chapter describing how to run the ready to use images.

With docker-compose.yml:

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

Test your developement:

If you would contribute or test your development, update the code, and rebuild the docker container, see the step 2.

Clone this wiki locally