I have just installed docker toolbox on windows environnement (Windows 7 Pro) and I have got a network time out due to the entreprise proxy. How can I set the proxy in docker toolbox ?
Thanks for your help.
I have just installed docker toolbox on windows environnement (Windows 7 Pro) and I have got a network time out due to the entreprise proxy. How can I set the proxy in docker toolbox ?
Thanks for your help.
I encountered the same problem. Here is my solution.
Env:
Win7, Docker Toolbox 17.03, cmder terminal, behind enterprise proxy setting.
Solution:
in C:\Program Files\Docker Toolbox, find start.sh file. add following two proxy settings:
export http_proxy="http://hostname:port/"
export https_proxy="http://hostname:port/"
At least, it works for me.
export http_proxy="http://hostname:port/" export https_proxy="http://hostname:port/"
after the first trap ...
command in the start.sh
file. –
Sob I have a similar problem for Windows 7 but it was resolved by these steps :
Step 1. Create a batch script C:\Program Files\Docker Toolbox\kitematic_proxy.cmd with below configuration
set proxy=YOUR_PROXY
SET HTTP_PROXY=%proxy%
SET HTTPS_PROXY=%proxy%
for /f %%i in ('docker-machine.exe ip default') do set DOCKER_HOST=%%i
SET NO_PROXY=%DOCKER_HOST%
set DOCKER_HOST=tcp://%DOCKER_HOST%:2376
cd Kitematic
Kitematic.exe
Step 2. Open Oracle Virtual machine from the start menu , go to command prompt by clicking Show (Make sure your Oracle Vm is up and running)
enter sudo vi /var/lib/boot2docker/profile
add this lines
export HTTP_PROXY=http://your.proxy.name:8080
export HTTPS_PROXY=http://your.proxy.name:8080
use your proxy address & port
this link help me a lot https://github.com/docker/kitematic/wiki/Common-Proxy-Issues-&-Fixes
Note:
Installing docker on windows 7 (docker 18.09.0) behind an enterprise proxy was quite complicated for me. Here are the steps I followed:
choco install docker-toolbox
(Warning! Don't use Docker for windows, as it targets Windows 10)docker-machine ls
should be empty. If not run: docker-machine rm default
)docker-machine --native-ssh create -d virtualbox --engine-env HTTP_PROXY=$HTTP_PROXY --engine-env HTTPS_PROXY=$HTTPS_PROXY default
.C:\Program Files\Docker Toolbox\start.sh
docker pull busybox
. This should work.I had an issue on my Windows 7 Docker toolbox installation
$ docker --version
Docker version 18.09.3, build 774a1f4eee
$ docker-compose --version
docker-compose version 1.23.2, build 1110ad01
When I tried
docker run hello-world
I received
Unable to find image 'hello-world:latest' locally C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while waiting headers). See 'C:\Program Files\Docker Toolbox\docker.exe run --help'.
According to https://docs.docker.com/toolbox/faqs/troubleshoot/ I've registered my enterprise proxy in /var/lib/boot2docker/profile
inside the docker machine:
Use
ssh
to log in to the virtual machine. This example logs in to thedefault
machine.$ docker-machine ssh default docker@default:~$ sudo vi /var/lib/boot2docker/profile
Then I added my enterprise proxy in the end of the profile
export "HTTP_PROXY=http://host:port"
export "HTTPS_PROXY=http://host:port"
after that I continued the instructions
Add a
NO_PROXY
setting to the end of the file similar to the example below.export "NO_PROXY=192.168.*.*"
Restart Docker. After you modify the
profile
on your VM, restart Docker and log out of the machine.docker@default:~$ sudo /etc/init.d/docker restart docker@default:~$ exit
After that docker run hello-world
command works well
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
As @rsb2097 mentioned after every PC reboot Docker Machine lose the settings in /var/lib/boot2docker/profile
. I face the same problem too and I don't know how to avoid this, but I made a script to write these settings simpler.
I thought that happens because I shut down the PC without stopping the docker machine (VirtualBox says that there are active connections on shut down): supposed that it damages.
I tried docker-machine stop
but it doesn't help.
As a result I wrote AddDockerMachineProxy.cmd
script that writes the proxy settings using plink.exe
from Putty (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html).
Usage
Run Docker Quickstart Terminal
, I have following output:
Starting "default"...
(default) Check network to re-create if needed...
(default) Windows might ask for the permission to configure a dhcp server.
Sometimes, such confirmation window is minimized in the taskbar.
(default) Waiting for an IP...
Machine "default" was started.
Waiting for SSH to be available...
Detecting the provisioner...
Started machines may have new IP addresses.
You may need to re-run the `docker-machine env` command.
Regenerate TLS machine certs?
Warning: this is irreversible. (y/n): Regenerating TLS certificates
Waiting for SSH to be available...
Detecting the provisioner...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Run AddDockerMachineProxy.cmd
script (plink.exe
must be in %PATH%
):
@echo off
echo Was "Docker Quickstart Terminal" run after the reboot to init the machine?
echo If not this script fails.
pause
set "exePlink=plink.exe"
set "connectionString=-pw tcuser [email protected]"
echo Profile BEFORE:
call "%exePlink%" %connectionString% cat /var/lib/boot2docker/profile
if errorlevel 1 ( echo ERROR: PSCP failed !!! & goto BadExit )
echo APPENDING PROXY
call "%exePlink%" %connectionString% sudo bash -c "'echo export \"HTTP_PROXY=http://host:port\">> /var/lib/boot2docker/profile'"
if errorlevel 1 ( echo ERROR: PSCP failed !!! & goto BadExit )
call "%exePlink%" %connectionString% sudo bash -c "'echo export \"HTTPS_PROXY=http://host:port\">> /var/lib/boot2docker/profile'"
if errorlevel 1 ( echo ERROR: PSCP failed !!! & goto BadExit )
call "%exePlink%" %connectionString% sudo bash -c "'echo export \"NO_PROXY=192.168.*.*\">> /var/lib/boot2docker/profile'"
if errorlevel 1 ( echo ERROR: PSCP failed !!! & goto BadExit )
echo Profile AFTER:
call "%exePlink%" %connectionString% cat /var/lib/boot2docker/profile
if errorlevel 1 ( echo ERROR: PSCP failed !!! & goto BadExit )
echo Restart docker service:
call "%exePlink%" %connectionString% sudo /etc/init.d/docker restart
if errorlevel 1 ( echo ERROR: PSCP failed !!! & goto BadExit )
echo Testing connection
call docker image pull hello-world || ( echo ERROR: docker image pull is failed !!! & goto BadExit )
echo Done!
exit /b 0
:BadExit
echo ERROR !!!
exit /b 1
docker-machine stop
but it doesn't help. As a result I wrote .cmd
-script that writes the proxy settings using plink.exe
from Putty (chiark.greenend.org.uk/~sgtatham/putty/latest.html). I will add my script in the answer. –
Slippage bash
to sh
–
Salubrious Ah! Actually with Docker Toolbox windows part is just very thin layer over created virtual machine, so my method is to configure virtual machine itself to make everything work. So.
0) Set global environment variables on Windows host machine
HTTP_PROXY = "http://login:password@yourproxy:8080"
HTTPS_PROXY = "http://login:password@yourproxy:8080"
Note caps letters! (also you can set FTP_PROXY
and NO_PROXY
)
1) Run Docker Quickstart Terminal, it will create virtual machine named default
under you VirtualBox or whatever. Also it will display address of your newly created VM like
docker is configured to use the default machine with IP 192.168.99.104
2) SSH to this address (i.e. with PuTTY). Login:docker
Password:tcuser
3) Run
echo '
{
"proxies":
{
"default":
{
"httpProxy": "http://login:password@yourproxy:8080",
"httpsProxy": "http://login:password@yourproxy:8080"
}
}
}' > /home/docker/.docker/config.json
This will force docker client (on VM!) to run containers with correct envs inside.
4) So now you can use docker client inside VM. To force Windows docker client (as well as docker-compose) also to set correct envs inside running containers, put the same config.json
as in p.3 on Windows host machine to C:\User\<yourhomedir>\.docker
directory.
Now check the environment inside running container
docker run -ti ubuntu env
HTTPS_PROXY=http://login:password@yourproxy:8080
https_proxy=http://login:password@yourproxy:8080
HTTP_PROXY=http://login:password@yourproxy:8080
http_proxy=http://login:password@yourproxy:8080
Note both CAPS and lower letter variables are set properly!
Final check for everything is ok:
docker run -ti ubuntu apt-get update
5) One issue you may face, is that address of your proxy is from network, which docker use when creating own networks, so it will spoil route to your proxy right after you will do docker network create
. So make sure the proxy address is not like 172.18.x.x . If so force docker to use another address space for created networks by making another config on VM
sudo -i
echo '
{
"default-address-pools": [
{"base":"172.80.0.0/16","size":24}
]
}' > /etc/docker/daemon.json
Then restart dockerd /etc/init.d/docker restart
6) Do not restart your virtual machine, pause it when needed.
© 2022 - 2024 — McMap. All rights reserved.
#!/bin/bash export http_proxy="http://[user]:[password]@hostname:port/" export https_proxy="http://[user]:[password]@hostname:port/"
– Tarshatarshish