├── Dockerfile ├── entrypoint.sh ├── LICENSE └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:jessie 2 | MAINTAINER David Stefan 3 | 4 | RUN apt-get update && \ 5 | DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends rsync && \ 6 | apt-get clean autoclean && \ 7 | apt-get autoremove -y && \ 8 | rm -rf /var/lib/apt/lists/* 9 | 10 | EXPOSE 873 11 | ADD ./entrypoint.sh /entrypoint.sh 12 | RUN chmod +x /entrypoint.sh 13 | 14 | ENTRYPOINT ["/entrypoint.sh"] 15 | -------------------------------------------------------------------------------- /entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | VOLUME=${VOLUME:-/volume} 3 | ALLOW=${ALLOW:-192.168.0.0/16 172.16.0.0/12} 4 | USER=${USER:-nobody} 5 | GROUP=${GROUP:-nogroup} 6 | 7 | mkdir -p ${VOLUME} 8 | 9 | getent group ${GROUP} > /dev/null || addgroup ${GROUP} 10 | getent passwd ${USER} > /dev/null || adduser -D -H -G ${GROUP} ${USER} 11 | chown -R ${USER}:${GROUP} ${VOLUME} 12 | 13 | cat < /etc/rsyncd.conf 14 | uid = ${USER} 15 | gid = ${GROUP} 16 | use chroot = yes 17 | log file = /dev/stdout 18 | reverse lookup = no 19 | [volume] 20 | hosts deny = * 21 | hosts allow = ${ALLOW} 22 | read only = false 23 | path = ${VOLUME} 24 | comment = docker volume 25 | EOF 26 | 27 | exec /usr/bin/rsync --no-detach --daemon --config /etc/rsyncd.conf 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 David Stefan 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # rsync 2 | 3 | A minimalist image with rsync daemon. It is intended to be used as a volume and shared among containers where standard volume sharing results in poor read performance. 4 | 5 | # Usage 6 | 7 | The simplest use case is to run the image and map its 873 port: 8 | ```bash 9 | $ docker run stefda/rsync -p 873:873 10 | ``` 11 | 12 | The command above spins up a container that will listen on port 873 for connections over the native rsync protocol. Syncing files is then as easy as `rsync -rtR rsync://:873/volume`. 13 | 14 | # Configuration 15 | 16 | The module path, owning user, group and allowed hosts are all configurable via environmental variables. Launch fully customised container like so: 17 | 18 | ```bash 19 | $ docker run stefda/rsync -p 873:873 -e VOLUME=/my/volume -e USER=www-data -e GROUP=www-data -e ALLOW="192.168.0.0/16 10.0.0.0/16" 20 | ``` 21 | 22 | # Using the image with docker-compose 23 | 24 | An example usage with docker-compose: 25 | 26 | ```yaml 27 | version: '2' 28 | services: 29 | rsync-volume: 30 | image: stefda/rsync 31 | volumes: 32 | - /var/www/app/src 33 | environment: 34 | VOLUME: /var/www/app 35 | USER: www-data 36 | GROUP: www-data 37 | ports: 38 | - 10873:873 39 | 40 | web: 41 | image: my-app-image 42 | volumes_from: 43 | - rsync-volume 44 | ``` 45 | 46 | As defined, the `web` service will have volumes from the `rsync-volume` service and so any files synced into the rsync container will be immediately available in `web` as well. 47 | --------------------------------------------------------------------------------