ThomasReggi
ThomasReggi

Reputation: 59475

docker cannot access intranet that host can

I am behind a corporate proxy. I have HTTP_PROXY, HTTPS_PROXY, and NO_PROXY set in the image. When I'm connected to the network I have access to a private npm registry that is on this intranet. My docker image is unable to access this registry.

On the host machine, a mac, I can run:

curl https://<registry>/nodejs/content/groups/npm/lodash

And I get the JSON for the package.

On the docker image I run the same command and I get this:

curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

When I npm install with the registry set it also returns the same issue.

Why can't docker access the same endpoint that my host machine can? How can I enable it to?

Upvotes: 1

Views: 3034

Answers (3)

Deo Leung
Deo Leung

Reputation: 908

I encountered a similar issue, which was there is a docker network created by some compose file remains there

docker network ls

I removed the danging one and retain the intranet access

Upvotes: 1

lleon
lleon

Reputation: 2765

A bit late but it migh thelp someone. I had the same problem and my solution was configure docker daemon to use my intranet DNS

Edit the daemon.json file

sudo vim /etc/docker/daemon.json

The file should look something like this

{
  "dns": ["ip-here", "ip-here"]
}

Restart de daemon

sudo service docker restart

Upvotes: 0

Fabian Rivera
Fabian Rivera

Reputation: 1198

Try using the host's network. If you are able to access that URL from your local, then it should work. You just need to add the --network host argument to your build/run command.

Example:

$ docker build <all the other args> --network host .
$ docker run <all the other args> --network host .

Docker creates a bridge network by default but you can force it to use your local network with --network host arg.

Upvotes: 1

Related Questions