Connect docker container to VPN

2019-09-11 20:49发布

I have a docker container from which I build and package a Java application with maven 3. I have some dependencies deployed to a Nexus server, I can only access through a VPN from local. How can I connect my docker container to that VPN?

docker image details:

Base image : Ubuntu 16.04 LTS as base system

Java 8, maven 3, Tomcat 8 installed

To create my docker container (I didn't add any network configuration):

docker run -it --rm -v '$PWD':/app -w /app/app-parent appImage/v:02 mvn clean install

And that's the error i get:

INFO: I/O exception (java.net.NoRouteToHostException) caught when processing request to {}->http://myserver:80: No route to host (Host unreachable)

1条回答
冷血范
2楼-- · 2019-09-11 21:17

May be your problem is due to DNS only.

Try resolving nexus hostname in the container's /etc/hosts file (or change maven settings.xml so that tag of nexus repository looks for the ip instead of the hostname).

To check if that is the problem, simply connect to the container

docker exec -ti yourContainer /bin/bash

then try to contact the host (depending on what you installed on the container, you could use ping, wget or other) with hostaname and ip address.

查看更多
登录 后发表回答