diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-08-17 00:04:53 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-08-17 00:04:53 +0200 |
commit | 671997ed586173d92a4776bc1dc92541e90ecb52 (patch) | |
tree | 3f54a122bd462915c73fb03e75d8584beb07e14d /contrib | |
parent | 744f39a476ef16b0efd08f2662b0a72c5cd3e149 (diff) | |
download | gnunet-671997ed586173d92a4776bc1dc92541e90ecb52.tar.gz gnunet-671997ed586173d92a4776bc1dc92541e90ecb52.zip |
also move docker/ to contrib
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/docker/README.md | 138 | ||||
-rw-r--r-- | contrib/docker/docker-entrypoint.sh | 15 | ||||
-rw-r--r-- | contrib/docker/gnunet.conf | 21 |
3 files changed, 174 insertions, 0 deletions
diff --git a/contrib/docker/README.md b/contrib/docker/README.md new file mode 100644 index 000000000..ce05012fc --- /dev/null +++ b/contrib/docker/README.md | |||
@@ -0,0 +1,138 @@ | |||
1 | # gnunet-docker | ||
2 | A Dockerfile (and maybe later docker-compose.yml) for getting a running GNUnet docker container. | ||
3 | |||
4 | > This README and parts of the Dockerfile were adapted from https://github.com/compiaffe/gnunet-docker | ||
5 | |||
6 | |||
7 | ## Build it | ||
8 | This will take quite a while and will consume a bit of data. | ||
9 | |||
10 | First you need to go to the root of this repo. | ||
11 | |||
12 | ```bash | ||
13 | cd .. | ||
14 | ``` | ||
15 | |||
16 | Now you can build the image. | ||
17 | |||
18 | ```bash | ||
19 | docker build -t gnunet . | ||
20 | ``` | ||
21 | |||
22 | ## Start it from the newly created gnunet image | ||
23 | Start a container from `gnunet` image, which can access /dev/net/tun, has access to the host network. We are going to name it `gnunet1`. | ||
24 | |||
25 | Note the `--rm` that will delete the container as soon as you stop it and `-ti` gives you an interactive terminal. | ||
26 | |||
27 | #### Linux Users | ||
28 | ```bash | ||
29 | docker run \ | ||
30 | --rm \ | ||
31 | -ti \ | ||
32 | --privileged \ | ||
33 | --name gnunet1 \ | ||
34 | --net=host \ | ||
35 | -v /dev/net/tun:/dev/net/tun \ | ||
36 | gnunet | ||
37 | ``` | ||
38 | |||
39 | #### Mac Users | ||
40 | ```bash | ||
41 | docker run \ | ||
42 | --rm \ | ||
43 | -it \ | ||
44 | --privileged \ | ||
45 | --name gnunet1 \ | ||
46 | -e LOCAL_PORT_RANGE='40001 40200' \ | ||
47 | -e GNUNET_PORT=2086 \ | ||
48 | -p 2086:2086 \ | ||
49 | -p 2086:2086/udp \ | ||
50 | -p40001-40200:40001-40200 \ | ||
51 | -p40001-40200:40001-40200/udp \ | ||
52 | gnunet | ||
53 | ``` | ||
54 | |||
55 | This terminal will keep on printing to screen at the moment. So go on in a new terminal please. | ||
56 | |||
57 | Don't worry about warnings too much... | ||
58 | |||
59 | ## Check if you are connected | ||
60 | Open a new terminal and connect to the container we just started: | ||
61 | |||
62 | ```bash | ||
63 | docker exec -it gnunet1 gnunet-peerinfo -i | ||
64 | ``` | ||
65 | |||
66 | If you get a list of peers, all is good. | ||
67 | |||
68 | ## Multiple containers on the same host | ||
69 | ### Running | ||
70 | #### Run Container 1 | ||
71 | ```bash | ||
72 | export GPORT=2086 LPORT='40001-40200' GNAME=gnunet1 | ||
73 | docker run \ | ||
74 | --rm \ | ||
75 | -it \ | ||
76 | --privileged \ | ||
77 | -e GNUNET_PORT=$GPORT \ | ||
78 | -e LOCAL_PORT_RANGE="${LPORT/-/ }" \ | ||
79 | -p $GPORT:$GPORT \ | ||
80 | -p $GPORT:$GPORT/udp \ | ||
81 | -p$LPORT:$LPORT \ | ||
82 | -p$LPORT:$LPORT/udp \ | ||
83 | --name $GNAME \ | ||
84 | gnunet | ||
85 | ``` | ||
86 | |||
87 | #### Run Container 2 | ||
88 | ```bash | ||
89 | export GPORT=2087 LPORT='40201-40400' GNAME=gnunet2 | ||
90 | docker run \ | ||
91 | --rm \ | ||
92 | -it \ | ||
93 | --privileged \ | ||
94 | -e GNUNET_PORT=$GPORT \ | ||
95 | -e LOCAL_PORT_RANGE="${LPORT/-/ }" \ | ||
96 | -p $GPORT:$GPORT \ | ||
97 | -p $GPORT:$GPORT/udp \ | ||
98 | -p$LPORT:$LPORT \ | ||
99 | -p$LPORT:$LPORT/udp \ | ||
100 | --name $GNAME \ | ||
101 | gnunet | ||
102 | ``` | ||
103 | |||
104 | ### Testing cadet example | ||
105 | #### Container 1 | ||
106 | ```bash | ||
107 | $ docker exec -it gnunet1 bash | ||
108 | $ gnunet-peerinfo -s | ||
109 | I am peer `VWPN1NZA6YMM866EJ5J2NY47XG692MQ6H6WASVECF0M18A9SCMZ0'. | ||
110 | $ gnunet-cadet -o asdasd | ||
111 | ``` | ||
112 | |||
113 | #### Container 2 | ||
114 | ```bash | ||
115 | $ docker exec -it gnunet2 bash | ||
116 | $ gnunet-cadet VWPN1NZA6YMM866EJ5J2NY47XG692MQ6H6WASVECF0M18A9SCMZ0 asdasd | ||
117 | ``` | ||
118 | |||
119 | ### Testing file sharing example | ||
120 | #### Container 1 | ||
121 | ```bash | ||
122 | $ docker exec -it gnunet1 bash | ||
123 | $ echo 'test' > test.txt | ||
124 | $ gnunet-publish test.txt | ||
125 | Publishing `/test.txt' done. | ||
126 | URI is `gnunet://fs/chk/1RZ7A8TAQHMF8DWAGTSZ9CSA365T60C4BC6DDS810VM78D2Q0366CRX8DGFA29EWBT9BW5Y9HYD0Z1EAKNFNJQDJ04QQSGTQ352W28R.7MYB03GYXT17Z93ZRZRVV64AH9KPWFSVDEZGVE84YHD63XZFJ36B86M48KHTZVF87SZ05HBVB44PCXE8CVWAH72VN1SKYPRK1QN2C98.5'. | ||
127 | ``` | ||
128 | |||
129 | #### Container 2 | ||
130 | ```bash | ||
131 | $ docker exec -it gnunet2 bash | ||
132 | $ gnunet-download -o out.file "gnunet://fs/chk/1RZ7A8TAQHMF8DWAGTSZ9CSA365T60C4BC6DDS810VM78D2Q0366CRX8DGFA29EWBT9BW5Y9HYD0Z1EAKNFNJQDJ04QQSGTQ352W28R.7MYB03GYXT17Z93ZRZRVV64AH9KPWFSVDEZGVE84YHD63XZFJ36B86M48KHTZVF87SZ05HBVB44PCXE8CVWAH72VN1SKYPRK1QN2C98.5" | ||
133 | 100% [============================================================] | ||
134 | Downloading `out.file' done (0 b/s). | ||
135 | $ cat out.file | ||
136 | test | ||
137 | ``` | ||
138 | |||
diff --git a/contrib/docker/docker-entrypoint.sh b/contrib/docker/docker-entrypoint.sh new file mode 100644 index 000000000..7f98ef68b --- /dev/null +++ b/contrib/docker/docker-entrypoint.sh | |||
@@ -0,0 +1,15 @@ | |||
1 | #!/bin/bash -e | ||
2 | |||
3 | echo "${LOCAL_PORT_RANGE:-49152 65535}" > /proc/sys/net/ipv4/ip_local_port_range | ||
4 | sed -i 's/$GNUNET_PORT/'${GNUNET_PORT:-2086}'/g' /etc/gnunet.conf | ||
5 | |||
6 | if [[ $# -eq 0 ]]; then | ||
7 | exec gnunet-arm \ | ||
8 | --config=/etc/gnunet.conf \ | ||
9 | --start \ | ||
10 | --monitor | ||
11 | elif [[ -z $1 ]] || [[ ${1:0:1} == '-' ]]; then | ||
12 | exec gnunet-arm "$@" | ||
13 | else | ||
14 | exec "$@" | ||
15 | fi | ||
diff --git a/contrib/docker/gnunet.conf b/contrib/docker/gnunet.conf new file mode 100644 index 000000000..c8299ef46 --- /dev/null +++ b/contrib/docker/gnunet.conf | |||
@@ -0,0 +1,21 @@ | |||
1 | [arm] | ||
2 | SYSTEM_ONLY = NO | ||
3 | USER_ONLY = NO | ||
4 | |||
5 | [fs] | ||
6 | FORCESTART = NO | ||
7 | |||
8 | [nat] | ||
9 | ENABLE_UPNP = NO | ||
10 | BEHIND_NAT = YES | ||
11 | |||
12 | [transport-tcp] | ||
13 | PORT = $GNUNET_PORT | ||
14 | ADVERTISED_PORT = $GNUNET_PORT | ||
15 | |||
16 | [transport-udp] | ||
17 | PORT = $GNUNET_PORT | ||
18 | BROADCAST = YES | ||
19 | |||
20 | [cadet] | ||
21 | TESTING_IGNORE_KEYS = ACCEPT_FROM; | ||