aboutsummaryrefslogtreecommitdiff
path: root/contrib/docker/README.md
blob: 66ba45d264ee3d2b42bfdc03b46997b877e7e1e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# gnunet-docker
A Dockerfile (and maybe later docker-compose.yml) for getting a running GNUnet docker container.

> This README and parts of the Dockerfile were adapted from https://github.com/compiaffe/gnunet-docker


## Build it
This will take quite a while and will consume a bit of data.

First you need to go to the root of this repo.

```bash
cd ../..
```

Now you can build the image.

```bash
make clean
docker build -f contrib/docker/Dockerfile -t gnunet .
```

## Start it from the newly created gnunet image
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`.

Note the `--rm` that will delete the container as soon as you stop it and `-ti` gives you an interactive terminal.

#### Linux Users
```bash
docker run \
  --rm \
  -ti \
  --privileged \
  --name gnunet1 \
  --net=host \
  -v /dev/net/tun:/dev/net/tun \
  gnunet
```

#### Mac Users
```bash
docker run \
  --rm \
  -it \
  --privileged \
  --name gnunet1 \
  -e LOCAL_PORT_RANGE='40001 40200' \
  -e GNUNET_PORT=2086 \
  -p 2086:2086 \
  -p 2086:2086/udp \
  -p40001-40200:40001-40200 \
  -p40001-40200:40001-40200/udp \
  gnunet
```

This terminal will keep on printing to screen at the moment. So go on in a new terminal please.

Don't worry about warnings too much...

## Check if you are connected
Open a new terminal and connect to the container we just started:

```bash
docker exec -it gnunet1 gnunet-peerinfo -i
```

If you get a list of peers, all is good.

## Multiple containers on the same host
### Running
#### Run Container 1
```bash
export GPORT=2086 LPORT='40001-40200' GNAME=gnunet1
docker run \
  --rm \
  -it \
  --privileged \
  -e GNUNET_PORT=$GPORT \
  -e LOCAL_PORT_RANGE="${LPORT/-/ }" \
  -p $GPORT:$GPORT \
  -p $GPORT:$GPORT/udp \
  -p$LPORT:$LPORT \
  -p$LPORT:$LPORT/udp \
  --name $GNAME \
  gnunet
```

#### Run Container 2
```bash
export GPORT=2087 LPORT='40201-40400' GNAME=gnunet2
docker run \
  --rm \
  -it \
  --privileged \
  -e GNUNET_PORT=$GPORT \
  -e LOCAL_PORT_RANGE="${LPORT/-/ }" \
  -p $GPORT:$GPORT \
  -p $GPORT:$GPORT/udp \
  -p$LPORT:$LPORT \
  -p$LPORT:$LPORT/udp \
  --name $GNAME \
  gnunet
```

### Testing cadet example
#### Container 1
```bash
$ docker exec -it gnunet1 bash
$ gnunet-peerinfo -s
I am peer `VWPN1NZA6YMM866EJ5J2NY47XG692MQ6H6WASVECF0M18A9SCMZ0'.
$ gnunet-cadet -o asdasd
```

#### Container 2
```bash
$ docker exec -it gnunet2 bash
$ gnunet-cadet VWPN1NZA6YMM866EJ5J2NY47XG692MQ6H6WASVECF0M18A9SCMZ0 asdasd
```

### Testing file sharing example
#### Container 1
```bash
$ docker exec -it gnunet1 bash
$ echo 'test' > test.txt
$ gnunet-publish test.txt
Publishing `/test.txt' done.
URI is `gnunet://fs/chk/1RZ7A8TAQHMF8DWAGTSZ9CSA365T60C4BC6DDS810VM78D2Q0366CRX8DGFA29EWBT9BW5Y9HYD0Z1EAKNFNJQDJ04QQSGTQ352W28R.7MYB03GYXT17Z93ZRZRVV64AH9KPWFSVDEZGVE84YHD63XZFJ36B86M48KHTZVF87SZ05HBVB44PCXE8CVWAH72VN1SKYPRK1QN2C98.5'.
```

#### Container 2
```bash
$ docker exec -it gnunet2 bash
$ gnunet-download -o out.file "gnunet://fs/chk/1RZ7A8TAQHMF8DWAGTSZ9CSA365T60C4BC6DDS810VM78D2Q0366CRX8DGFA29EWBT9BW5Y9HYD0Z1EAKNFNJQDJ04QQSGTQ352W28R.7MYB03GYXT17Z93ZRZRVV64AH9KPWFSVDEZGVE84YHD63XZFJ36B86M48KHTZVF87SZ05HBVB44PCXE8CVWAH72VN1SKYPRK1QN2C98.5"
100% [============================================================]
Downloading `out.file' done (0 b/s).
$ cat out.file
test
```