├── .dockerignore ├── .editorconfig ├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ └── publish-image.yaml ├── Dockerfile ├── LICENSE ├── Makefile └── README.md /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | LICENSE 3 | Makefile 4 | README.md 5 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_size = 4 6 | indent_style = space 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [*.{yml,yaml}] 11 | indent_style = space 12 | indent_size = 2 13 | 14 | [Makefile] 15 | indent_style = tab 16 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: PHLAK 2 | patreon: PHLAK 3 | custom: https://paypal.me/ChrisKankiewicz 4 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: docker 4 | directory: "/" 5 | schedule: 6 | interval: monthly 7 | timezone: US/Arizona 8 | open-pull-requests-limit: 10 9 | -------------------------------------------------------------------------------- /.github/workflows/publish-image.yaml: -------------------------------------------------------------------------------- 1 | name: Publish Image 2 | 3 | on: 4 | push: 5 | branches: ['master'] 6 | tags: ['*'] 7 | pull_request: 8 | branches: ['master'] 9 | 10 | env: 11 | DOCKER_HUB_USER: phlak 12 | 13 | jobs: 14 | build-container: 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout Repository 19 | uses: actions/checkout@v2 20 | 21 | - name: Log in to Docker Hub 22 | uses: docker/login-action@v1 23 | with: 24 | username: ${{ env.DOCKER_HUB_USER }} 25 | password: ${{ secrets.DOCKER_HUB_TOKEN }} 26 | 27 | - name: Extract Metadata 28 | id: extract-metadata 29 | uses: docker/metadata-action@v3 30 | with: 31 | images: ${{ env.DOCKER_HUB_USER }}/openvpn 32 | tags: | 33 | type=raw,value=latest 34 | type=ref,event=tag 35 | 36 | - name: Build & Push Image 37 | uses: docker/build-push-action@v2 38 | with: 39 | push: ${{ github.event_name != 'pull_request' }} 40 | tags: ${{ steps.extract-metadata.outputs.tags }} 41 | labels: ${{ steps.extract-metadata.outputs.labels }} 42 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine:3.15.3 2 | LABEL maintainer="Chris Kankiewicz " 3 | 4 | # Define OpenVPN version 5 | ARG OVPN_VERSION=2.5.6-r0 6 | 7 | # Create OpenVPN conf directory 8 | RUN mkdir -p /vol/config 9 | 10 | # Install OpenVPN 11 | RUN apk add --update openvpn=${OVPN_VERSION} && rm -rf /var/cache/apk/* 12 | 13 | # Set working directory 14 | WORKDIR /vol/config 15 | 16 | # Defualt entrypoint and run command 17 | ENTRYPOINT ["openvpn", "--config", "/vol/config/openvpn.conf", "--verb", "3", "--remap-usr1", "SIGTERM"] 18 | CMD ["--script-security", "2", "--up", "/etc/openvpn/up.sh", "--down", "/etc/openvpn/down.sh"] 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Chris Kankiewicz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | IMAGE_NAME="phlak/openvpn" 2 | IMAGE_TAG="$$(grep 'ARG OVPN_VERSION' Dockerfile | awk -F = '{print $$2}')" 3 | 4 | build: 5 | @docker build --force-rm --pull --tag $(IMAGE_NAME):$(IMAGE_TAG) . 6 | 7 | purge: 8 | @docker image rm --force $(IMAGE_NAME):$(IMAGE_TAG) 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-openvpn 2 | ============== 3 | 4 |

5 | Join the Community 6 | Become a Sponsor 7 | One-time Donation 8 |
9 | Docker Image Version 10 | Docker Pulls 11 | License 12 | Docker Cloud Build Status 13 |

14 | 15 |

16 | Docker image for OpenVPN client/server. 17 |

18 | 19 | --- 20 | 21 | This container can run as an OpenVPN server or as an OpenVPN client and provide a VPN tunnel for 22 | other containers to utilize via Docker's shared networking stack (i.e. `--net container:[NAME]`). 23 | 24 | Running the Container 25 | --------------------- 26 | 27 | Place your OpenVPN client/server configuration file in a directory on your host file system 28 | (i.e. `/srv/openvpn`) with the name `openvpn.conf`. You should also place your client/server certs, 29 | keys and any additional files required in this directory. 30 | 31 | 32 | #### Running as an OpenVPN server 33 | 34 | Run the OpenVPN container and map your local config directory (`/srv/openvpn`) to the container 35 | config directory (`/vol/config`) and map ports to your host OS: 36 | 37 | docker run -d -v /srv/openvpn:/vol/config -p 443:443 -p 943:943 -p 1194:1194/udp --privileged --name openvpn-server phlak/openvpn --server [NETWORK] [NETMASK] 38 | 39 | 40 | #### Running as an OpenVPN client 41 | 42 | Run the OpenVPN container and map your local config directory (`/srv/openvpn`) to the container 43 | config directory (`/vol/config`): 44 | 45 | docker run -d -v /srv/openvpn:/vol/config --privileged --name openvpn-client phlak/openvpn 46 | 47 | Now you can start up another container with a shared network stack to the OpenVPN container: 48 | 49 | docker run -d --net container:openvpn-client --name container-name alpine 50 | 51 | This container will now be reliant on the OpenVPN container's network stack for network access. 52 | 53 | 54 | #### Optional 'docker run' Arguments 55 | 56 | `-p 1234:1234` - Map a port on the host OS to the OpenVPN container. When running as a client this 57 | will pass ports through to containers that share the OpenVPN container's network 58 | stack (i.e. When ran with the `--net container:openvpn-client` parameter). 59 | 60 | `--restart always` - Always restart the container regardless of the exit status. See the Docker 61 | [restart policies](https://goo.gl/OI87rA) for additional details. 62 | 63 | 64 | Troubleshooting 65 | --------------- 66 | 67 | When running a client container, if you are having trouble making a connection and `docker logs` 68 | shows `Initialization Sequence Completed` without indicatiing any problems try manually setting your 69 | container's DNS servers by adding `--dns 1.1.1.1 --dns 1.0.0.1` to your run command. Once your 70 | container is running check you DNS name servers with: 71 | 72 | docker exec transmission-vpn cat /etc/resolv.conf 73 | 74 | For general help and support join our [GitHub Discussions](https://github.com/PHLAK/docker-openvpn/discussions) or reach out on [Twitter](https://twitter.com/PHLAK). 75 | 76 | Please report bugs to the [GitHub Issue Tracker](https://github.com/PHLAK/docker-openvpn/issues). 77 | 78 | 79 | Copyright 80 | --------- 81 | 82 | This project is licensed under the [MIT License](https://github.com/PHLAK/docker-openvpn/blob/master/LICENSE). 83 | --------------------------------------------------------------------------------