├── .dockerignore ├── Dockerfile ├── README.md ├── build.sh ├── docker-compose.yml └── root ├── aria2.conf.default └── init.sh /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | build.sh 4 | docker-compose.yml 5 | README.md 6 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:latest 2 | MAINTAINER OpenGG 3 | 4 | COPY root/ / 5 | 6 | RUN set -xe \ 7 | && apk add --no-cache aria2 \ 8 | && chmod +x /init.sh 9 | 10 | VOLUME /config /downloads 11 | 12 | EXPOSE 6800 13 | 14 | ENTRYPOINT ["/init.sh"] 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-aria2 2 | 3 | [![](https://images.microbadger.com/badges/version/opengg/aria2.svg)](https://microbadger.com/images/opengg/aria2 "Get your own version badge on microbadger.com") 4 | [![](https://images.microbadger.com/badges/image/opengg/aria2.svg)](https://microbadger.com/images/opengg/aria2 "Get your own image badge on microbadger.com") 5 | 6 | [![Docker Pulls](https://img.shields.io/docker/pulls/opengg/aria2.svg)](https://hub.docker.com/r/opengg/aria2/ "Docker Pulls") 7 | [![Docker Stars](https://img.shields.io/docker/stars/opengg/aria2.svg)](https://hub.docker.com/r/opengg/aria2/ "Docker Stars") 8 | [![Docker Automated](https://img.shields.io/docker/automated/opengg/aria2.svg)](https://hub.docker.com/r/opengg/aria2/ "Docker Automated") 9 | 10 | ## Usage 11 | 12 | 0. Prepare config and download directories with following commands. 13 | 14 | ```bash 15 | # Create config dir 16 | mkdir /storage/aria2/config 17 | 18 | # Get uid and gid, see below 19 | id 20 | 21 | # Set proper permissions. Change 1001:1002 to your own uid:gid . 22 | chown -R 1001:1002 /storage/aria2/config 23 | 24 | find /storage/aria2/config -type d -exec chmod 755 {} + 25 | find /storage/aria2/config -type f -exec chmod 644 {} + 26 | 27 | # Create download dir 28 | mkdir /storage/aria2/downloads 29 | 30 | # Set proper permissions. Change 1001:1002 to your own uid:gid . 31 | chown -R 1001:1002 /storage/aria2/downloads 32 | find /storage/aria2/downloads -type d -exec chmod 755 {} + 33 | find /storage/aria2/downloads -type f -exec chmod 644 {} + 34 | ``` 35 | 0. Put `aria2.conf` file in the config dir, with following content. 36 | 37 | ```ini 38 | save-session=/config/aria2.session 39 | input-file=/config/aria2.session 40 | save-session-interval=60 41 | 42 | dir=/downloads 43 | 44 | file-allocation=prealloc 45 | disk-cache=128M 46 | 47 | enable-rpc=true 48 | rpc-listen-port=6800 49 | rpc-allow-origin-all=true 50 | rpc-listen-all=true 51 | 52 | rpc-secret= 53 | 54 | auto-file-renaming=false 55 | 56 | max-connection-per-server=16 57 | min-split-size=1M 58 | split=16 59 | ``` 60 | 0. Run following command to start aria2 instance 61 | 62 | ```bash 63 | # Change 1001:1002 to your own uid:gid . 64 | docker run \ 65 | -d \ 66 | --name aria2 \ 67 | -u=1001:1002 \ 68 | -v /storage/aria2/config:/config \ 69 | -v /storage/aria2/downloads:/downloads \ 70 | -p 6800:6800 \ 71 | opengg/aria2 72 | ``` 73 | 74 | Note: 75 | * Make sure the download folder is writable by the given uid/gid. 76 | * `aria2.conf` will be created automatically if not exists. 77 | * Learn more about tuning `aria2.conf`: [Config reference](https://aria2.github.io/manual/en/html/aria2c.html#aria2-conf) 78 | 79 | ## Parameters 80 | 81 | The parameters are split into two halves, separated by a colon, the left hand side representing the host and the right the container side. 82 | For example with a port -p external:internal - what this shows is the port mapping from internal to external of the container. 83 | So -p 8080:80 would expose port 80 from inside the container to be accessible from the host's IP on port 8080 84 | `http://192.168.x.x:8080` would show you what's running INSIDE the container on port 80. 85 | 86 | 87 | * `-p 6800:6800` - the port(s) 88 | * `-v /storage/aria2/config:/config` - where aria2 should store config files and logs 89 | * `-v /storage/aria2/downloads:/downloads` - local path for downloads 90 | * `-u 1001` for UserID - see below for explanation 91 | * `-u 1001:1002` for GroupID - see below for explanation 92 | 93 | It is based on alpine linux, for shell access whilst the container is running do `docker exec -it opengg/aria2 /bin/sh`. 94 | 95 | ### User / Group Identifiers 96 | 97 | Sometimes when using data volumes (`-v` flags) permissions issues can arise between the host OS and the container. We avoid this issue by allowing you to specify the user. Ensure the data volume directory on the host is owned by the same user you specify and it will "just work" ™. 98 | 99 | In this instance `-u 1001:1002`. To find yours use `id user` as below: 100 | 101 | ```bash 102 | $ id dockeruser 103 | uid=1001(dockeruser) gid=1002(dockergroup) groups=1002(dockergroup) 104 | ``` 105 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | docker build \ 4 | --tag aria2-local \ 5 | --force-rm \ 6 | . 7 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2' 2 | services: 3 | aria2-local: 4 | user: '501:20' 5 | container_name: aria2-test 6 | image: aria2-local 7 | ports: 8 | - 6801:6800 9 | volumes: 10 | - /tmp/aria2-local/config:/config 11 | - /tmp/aria2-local/downloads:/downloads 12 | -------------------------------------------------------------------------------- /root/aria2.conf.default: -------------------------------------------------------------------------------- 1 | save-session=/config/aria2.session 2 | input-file=/config/aria2.session 3 | save-session-interval=60 4 | 5 | dir=/downloads 6 | 7 | file-allocation=prealloc 8 | disk-cache=128M 9 | 10 | enable-rpc=true 11 | rpc-listen-port=6800 12 | rpc-allow-origin-all=true 13 | rpc-listen-all=true 14 | 15 | rpc-secret= 16 | 17 | auto-file-renaming=false 18 | 19 | max-connection-per-server=16 20 | min-split-size=1M 21 | split=16 22 | -------------------------------------------------------------------------------- /root/init.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | UID=`id -u` 5 | GID=`id -g` 6 | 7 | echo 8 | echo "UID: $UID" 9 | echo "GID: $GID" 10 | echo 11 | 12 | echo "Setting conf" 13 | 14 | touch /config/aria2.session 15 | 16 | if [[ ! -e /config/aria2.conf ]] 17 | then 18 | cp /aria2.conf.default /config/aria2.conf 19 | fi 20 | 21 | echo "[DONE]" 22 | 23 | echo "Setting owner and permissions" 24 | 25 | chown -R $UID:$GID /config 26 | find /config -type d -exec chmod 755 {} + 27 | find /config -type f -exec chmod 644 {} + 28 | 29 | echo "[DONE]" 30 | 31 | echo "Starting aria2c" 32 | 33 | exec aria2c \ 34 | --conf-path=/config/aria2.conf \ 35 | > /dev/stdout \ 36 | 2 > /dev/stderr 37 | 38 | echo 'Exiting aria2' 39 | --------------------------------------------------------------------------------