From 32036c9822bf81e0d961227164664e2acc5559fd Mon Sep 17 00:00:00 2001 From: Quentin McGaw Date: Sat, 31 Mar 2018 20:33:45 -0400 Subject: [PATCH] Updated repo --- .dockerignore | 6 ++++ .travis.yml | 8 ++---- Dockerfile | 28 ++++++++++-------- README.md | 72 +++++++++++++++++++++++++++++----------------- docker-compose.yml | 17 +++++++++++ 5 files changed, 88 insertions(+), 43 deletions(-) create mode 100644 .dockerignore create mode 100644 docker-compose.yml diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..5c25781a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,6 @@ +.git/ +.travis.yml +readme/ +tun.sh +docker-compose.yml +README.md \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 2e024b0c..b2d64c0f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,7 @@ language: generic -sudo: required -dist: trusty - services: - docker - install: - - docker build . \ No newline at end of file + - docker build . +#after_script: +# - "curl -X POST " \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 991ec80b..07951a62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,16 @@ -FROM alpine -MAINTAINER Quentin McGaw -RUN mkdir /pia -WORKDIR /pia -COPY script.sh /pia -RUN apk add --no-cache --update openvpn && \ - apk add --no-cache --update --virtual build-dependencies curl unzip && \ - curl https://www.privateinternetaccess.com/openvpn/openvpn.zip > openvpn.zip && \ - unzip openvpn.zip && rm openvpn.zip && \ - apk del build-dependencies && \ - chmod +x script.sh -ENTRYPOINT ["/pia/script.sh"] \ No newline at end of file +FROM alpine:3.7 +LABEL maintainer="quentin.mcgaw@gmail.com" \ + description="VPN client container to private internet access servers based on Alpine Linux and OpenVPN" \ + size="?MB" \ + ram="?MB" \ + github="https://github.com/qdm12/private-internet-access-docker" +COPY script.sh . +RUN chmod +x script.sh && \ + apk add -q --progress --no-cache --update openvpn && \ + apk add -q --progress --no-cache --update --virtual build-dependencies wget unzip && \ + wget https://www.privateinternetaccess.com/openvpn/openvpn.zip && \ + unzip openvpn.zip && \ + rm openvpn.zip && \ + apk del -q --progress --purge build-dependencies && \ + rm -rf /var/cache/apk/* +ENTRYPOINT /script.sh \ No newline at end of file diff --git a/README.md b/README.md index 50d34e3c..137b7ed1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Private Internet Access Docker (OpenVPN, Alpine) +Docker VPN client to private internet access servers based on [Alpine Linux](https://alpinelinux.org/) and [OpenVPN](https://openvpn.net/) + [![PIA Docker OpenVPN](https://github.com/qdm12/private-internet-access-docker/raw/master/readme/title.png)](https://hub.docker.com/r/qmcgaw/private-internet-access/) [![Build Status](https://travis-ci.org/qdm12/private-internet-access-docker.svg?branch=master)](https://travis-ci.org/qdm12/private-internet-access-docker) -VPN client container to private internet access servers based on [Alpine Linux](https://alpinelinux.org/) and [OpenVPN](https://openvpn.net/) - It requires: - A Private Internet Access **username** and **password** - [Sign up](https://www.privateinternetaccess.com/pages/buy-vpn/) - [Docker](https://docs.docker.com/install/) installed on the host @@ -14,59 +14,79 @@ The PIA configuration files are downloaded from [the PIA website](https://www.pr ## Installation & Testing -1. Run the *tun.sh* script on your host machine to ensure you have the **tun** device setup +1. Run the [**tun.sh**](https://raw.githubusercontent.com/qdm12/private-internet-access-docker/master/tun.sh) script on your host machine to ensure you have the **tun** device setup ```bash + wget https://raw.githubusercontent.com/qdm12/private-internet-access-docker/master/tun.sh sudo chmod +x tun.sh ./tun.sh ``` -2. Obtaining the Docker image - - Option 1 of 2: Automated download from the Docker Hub Registry, simply go to step 3. - - Option 2 of 2: Build the image - 1. Download the repository files or `git clone` them - 2. With a terminal, go in the directory where the *Dockerfile* is located - 3. Build the image with: - - ```bash - sudo docker build -t qmcgaw/private-internet-access ./ - ``` - -3. Create a file *auth.conf* in `/yourhostpath` (for example), with: +1. Create a file *auth.conf* in `/yourhostpath` (for example), with: - On the first line: your PIA username (i.e. `js89ds7`) - On the second line: your PIA password (i.e. `8fd9s239G`) -4. Test the container by connecting another container to it - 1. Run the container interactively with (and change the `/yourhostpath/auth.conf`): + +### Using Docker only + +1. Test the container by connecting another container to it + 1. Run the container interactively with (and change `/yourhostpath/auth.conf`): ```bash - sudo docker run --rm --name=piaTEST --cap-add=NET_ADMIN \ + docker run --rm --name=piaTEST --cap-add=NET_ADMIN \ --device=/dev/net/tun --dns 209.222.18.222 --dns 209.222.18.218 \ - -e 'REGION=Romania' -v '/yourhostpath/auth.conf:/pia/auth.conf' \ + -e 'REGION=Germany' -v '/yourhostpath/auth.conf:/pia/auth.conf:ro' \ qmcgaw/private-internet-access ``` - Wait about **5** seconds for it to connect to the PIA server. - 2. Check your host IP address with: + Wait about 5 seconds for it to connect to the PIA server. + 1. Check your host IP address with: ```bash curl -s ifconfig.co ``` - 3. Run the **curl** Docker container using your *piaTEST* container with: + 1. Run the **curl** Docker container using your *piaTEST* container with: ```bash - sudo docker run --rm --net=container:piaTEST tutum/curl curl -s ifconfig.co + docker run --rm --net=container:piaTEST tutum/curl curl -s ifconfig.co ``` If the displayed IP address appears and is different that your host IP address, your PIA OpenVPN client works ! -5. Run the container as a daemon in the background with (and change the `/yourhostpath/auth.conf`): + +1. Run the container as a daemon in the background with (and change the `/yourhostpath/auth.conf`): ```bash - sudo docker run -d --restart=always --name=pia --cap-add=NET_ADMIN \ + docker run -d --restart=always --name=pia --cap-add=NET_ADMIN \ --device=/dev/net/tun --dns 209.222.18.222 --dns 209.222.18.218 \ - -e 'REGION=Romania' -v '/yourhostpath/auth.conf:/pia/auth.conf' \ + -e 'REGION=Germany' -v '/yourhostpath/auth.conf:/pia/auth.conf' \ qmcgaw/private-internet-access ``` + +### Using Docker Compose + +1. Download [**docker-compose.yml**](https://github.com/qdm12/private-internet-access-docker/blob/master/docker-compose.yml) +1. Edit it and change `yourpath` +1. Run the container as a daemon in the background with: + + ```bash + docker-compose up -d + ``` + + Wait about 5 seconds for it to connect to the PIA server. +1. Check your host IP address with: + + ```bash + curl -s ifconfig.co + ``` + +1. Run the **curl** Docker container using your *pia* container with: + + ```bash + docker run --rm --net=container:pia tutum/curl curl -s ifconfig.co + ``` + + If the displayed IP address appears and is different that your host IP address, your PIA OpenVPN client works ! + ## Connect other containers to it diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..4ba187e6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,17 @@ +version: '3' +services: + pia: + image: qmcgaw/private-internet-access + container_name: pia + cap_add: + - NET_ADMIN + devices: + - /dev/net/tun + dns: + - 209.222.18.222 + - 209.222.18.218 + volumes: + - /yourpath/auth.conf:/pia/auth.conf:ro + environment: + - REGION=Germany + restart: always \ No newline at end of file