├── .gitignore ├── .env.example ├── hooks ├── push └── build ├── FAQ.md ├── docker-compose.yml ├── LICENSE.md ├── Dockerfile └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | SCRCPY_GRAPHICS_TYPE= -------------------------------------------------------------------------------- /hooks/push: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | for target in amd intel nvidia; do 5 | docker push "$DOCKER_REPO:$target" 6 | done 7 | -------------------------------------------------------------------------------- /FAQ.md: -------------------------------------------------------------------------------- 1 | 2 | # Frequenty Asked Questions 3 | 4 | ## scrcpy fails with: "ERROR: Could not open video stream" 5 | 6 | Try limiting the video dimensions. (e.g. `scrcpy -m 1024`) 7 | 8 | -------------------------------------------------------------------------------- /hooks/build: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -ex 3 | 4 | for target in amd intel nvidia; do 5 | docker build \ 6 | --tag "$DOCKER_REPO:$target" \ 7 | --target "$target" \ 8 | . 9 | done 10 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3.7' 2 | 3 | services: 4 | scrcpy: 5 | image: pierlo1/scrcpy:${SCRCPY_GRAPHICS_TYPE:?Please set the SCRCPY_GRAPHICS_TYPE environment variable.} 6 | volumes: 7 | - /dev/bus/usb:/dev/bus/usb:ro 8 | - /tmp/.X11-unix:/tmp/.X11-unix:ro 9 | # preserve authorization keys 10 | - scrcpy_adb_keys:/root/.android 11 | environment: 12 | DISPLAY: $DISPLAY 13 | ADB_VENDOR_KEYS: /root/.android 14 | privileged: true 15 | tty: true 16 | 17 | volumes: 18 | scrcpy_adb_keys: 19 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Pierre Gordon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ### builder 2 | FROM alpine:edge AS builder 3 | 4 | ARG SCRCPY_VER=1.16 5 | ARG SERVER_HASH="94a79e05b4498d0460ab7bd9d12cbf05156e3a47bf0c5d1420cee1d4493b3832" 6 | 7 | RUN apk add --no-cache \ 8 | curl \ 9 | ffmpeg-dev \ 10 | gcc \ 11 | git \ 12 | make \ 13 | meson \ 14 | musl-dev \ 15 | openjdk8 \ 16 | pkgconf \ 17 | sdl2-dev 18 | 19 | RUN PATH=$PATH:/usr/lib/jvm/java-1.8-openjdk/bin 20 | RUN curl -L -o scrcpy-server https://github.com/Genymobile/scrcpy/releases/download/v${SCRCPY_VER}/scrcpy-server-v${SCRCPY_VER} 21 | RUN echo "$SERVER_HASH /scrcpy-server" | sha256sum -c - 22 | RUN git clone https://github.com/Genymobile/scrcpy.git 23 | RUN cd scrcpy && meson x --buildtype release --strip -Db_lto=true -Dprebuilt_server=/scrcpy-server 24 | RUN cd scrcpy/x && ninja 25 | 26 | ### runner 27 | FROM alpine:edge AS runner 28 | 29 | # needed for android-tools 30 | RUN echo http://dl-cdn.alpinelinux.org/alpine/edge/testing >> /etc/apk/repositories 31 | 32 | LABEL maintainer="Pierre Gordon " 33 | 34 | RUN apk add --no-cache \ 35 | android-tools \ 36 | ffmpeg \ 37 | virtualgl 38 | 39 | COPY --from=builder /scrcpy-server /usr/local/share/scrcpy/ 40 | COPY --from=builder /scrcpy/x/app/scrcpy /usr/local/bin/ 41 | 42 | ### runner (amd) 43 | FROM runner AS amd 44 | 45 | RUN apk add --no-cache mesa-dri-swrast 46 | 47 | ### runner (intel) 48 | FROM runner AS intel 49 | 50 | RUN apk add --no-cache mesa-dri-intel 51 | 52 | ### runner (nvidia) 53 | FROM runner AS nvidia 54 | 55 | RUN apk add --no-cache mesa-dri-nouveau 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Docker Build Status](https://img.shields.io/docker/build/pierlo1/scrcpy.svg)](https://hub.docker.com/r/pierlo1/scrcpy/) 2 | [![Docker Pulls](https://img.shields.io/docker/pulls/pierlo1/scrcpy.svg)](https://hub.docker.com/r/pierlo1/scrcpy/) 3 | [![AMD Size](https://img.shields.io/microbadger/image-size/pierlo1%2Fscrcpy/amd.svg?label=amd%20size)](https://hub.docker.com/r/pierlo1/scrcpy/) 4 | [![Intel Size](https://img.shields.io/microbadger/image-size/pierlo1%2Fscrcpy/intel.svg?label=intel%20size)](https://hub.docker.com/r/pierlo1/scrcpy/) 5 | [![Nvidia Size](https://img.shields.io/microbadger/image-size/pierlo1%2Fscrcpy/nvidia.svg?label=nvidia%20size)](https://hub.docker.com/r/pierlo1/scrcpy/) 6 | 7 | # scrcpy 8 | 9 | Docker image to run [scrcpy](https://github.com/Genymobile/scrcpy). 10 | 11 | ## Usage 12 | 13 | Before running the image, Docker must be allowed to connect to the X server: 14 | 15 | ```shell 16 | xhost + local:docker 17 | ``` 18 | 19 | A separate image has been built for AMD, Intel, & Nvidia graphics hardwares. 20 | To get the image for your hardware, simply append `:` to the image name (`pierlo1/scrcpy`) where graphics type can be: 21 | 22 | - amd 23 | - intel 24 | - nvidia 25 | 26 | For example: `pierlo1/scrcpy:amd`. 27 | 28 | ### Running with Docker 29 | 30 | To run the image with Docker run: 31 | 32 | ```shell 33 | docker run --rm -i -t --privileged \ 34 | -v /dev/bus/usb:/dev/bus/usb \ 35 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 36 | -e DISPLAY=$DISPLAY \ 37 | pierlo1/scrcpy: 38 | ``` 39 | 40 | ### Running with Docker Compose 41 | 42 | To run with Docker Compose, set the `SCRCPY_GRAPHICS_TYPE` environment variable to one of the graphics types mentioned earlier. 43 | For persistence, make a copy of `.env.example`, name it `.env`, and configure it. 44 | 45 | Once done, run the command: 46 | 47 | ```shell 48 | docker-compose run --rm scrcpy 49 | ``` 50 | 51 | The `scrcpy_adb_keys` volume is used to preserve the `adb` authorization keys. 52 | 53 | ### Running scrcpy 54 | 55 | Inside the container, verify you can see your Android device with: 56 | 57 | ```shell 58 | adb devices 59 | ``` 60 | Note: make sure the adb daemon is not running on the host (`adb kill-server`) to view devices in the container. 61 | 62 | And finally, run `scrcpy`: 63 | 64 | ```shell 65 | scrcpy [options] 66 | ``` 67 | --------------------------------------------------------------------------------