Skip to content

Commit c4fc888

Browse files
committed
Update documentation for docker-compose
1 parent be165e2 commit c4fc888

File tree

2 files changed

+51
-21
lines changed

2 files changed

+51
-21
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,17 @@ a corresponding [Digital Ocean Community Tutorial](http://bit.ly/1AGUZkq).
4040

4141
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn
4242

43+
## `docker-compose`
44+
45+
If you prefer to use `docker-compose` please refer to the [documentation](docs/docker-compose.md).
46+
4347
## Debugging Tips
4448

4549
* Create an environment variable with the name DEBUG and value of 1 to enable debug output (using "docker -e").
4650

4751
docker run -v $OVPN_DATA:/etc/openvpn -p 1194:1194/udp --privileged -e DEBUG=1 kylemanna/openvpn
4852

49-
* Test using a client that has openvpn installed correctly
53+
* Test using a client that has openvpn installed correctly
5054

5155
$ openvpn --config CLIENTNAME.ovpn
5256

docs/docker-compose.md

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,67 @@
22

33
* Add a new service in docker-compose.yml
44

5-
version: '2'
6-
services:
7-
openvpn:
8-
cap_add:
9-
- NET_ADMIN
10-
image: kylemanna/openvpn
11-
ports:
12-
- "1194:1194/udp"
13-
restart: always
14-
volumes:
15-
- ./openvpn/conf:/etc/openvpn
5+
```yaml
6+
version: '2'
7+
services:
8+
openvpn:
9+
cap_add:
10+
- NET_ADMIN
11+
image: kylemanna/openvpn
12+
container_name: openvpn
13+
ports:
14+
- "1194:1194/udp"
15+
restart: always
16+
volumes:
17+
- ./openvpn-data/conf:/etc/openvpn
18+
```
19+
1620
1721
* Initialize the configuration files and certificates
1822
19-
docker-compose run --rm openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
20-
docker-compose run --rm openvpn ovpn_initpki
21-
23+
```bash
24+
docker-compose run --rm openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
25+
docker-compose run --rm openvpn ovpn_initpki
26+
```
27+
2228
* Fix ownership (depending on how to handle your backups, this may not be needed)
2329

24-
sudo chown -R $(whoami): ./openvpn
30+
```bash
31+
sudo chown -R $(whoami): ./openvpn-data
32+
```
2533

2634
* Start OpenVPN server process
2735

28-
docker-compose up -d openvpn
36+
```bash
37+
docker-compose up -d openvpn
38+
```
39+
40+
* You can access the container logs with
41+
42+
```bash
43+
docker-compose logs -f
44+
```
2945

30-
* Generate a client certificate without a passphrase
46+
* Generate a client certificate
3147

32-
docker-compose run --rm openvpn easyrsa build-client-full CLIENTNAME nopass
48+
```bash
49+
export CLIENTNAME="your_client_name"
50+
# with a passphrase (recommended)
51+
docker-compose exec openvpn easyrsa build-client-full $CLIENTNAME
52+
# without a passphrase (not recommended)
53+
docker-compose exec openvpn easyrsa build-client-full $CLIENTNAME nopass
54+
```
3355

3456
* Retrieve the client configuration with embedded certificates
3557

36-
docker-compose run --rm openvpn ovpn_getclient CLIENTNAME > CLIENTNAME.ovpn
58+
```bash
59+
docker-compose exec openvpn ovpn_getclient $CLIENTNAME > $CLIENTNAME.ovpn
60+
```
3761

3862
## Debugging Tips
3963

4064
* Create an environment variable with the name DEBUG and value of 1 to enable debug output (using "docker -e").
4165

42-
docker-compose run -e DEBUG=1 openvpn
66+
```bash
67+
docker-compose run -e DEBUG=1 openvpn
68+
```

0 commit comments

Comments
 (0)