|
| 1 | +--- |
| 2 | +description: Troubleshooting connectivity and certificate issues |
| 3 | +keywords: beginner, getting started, FAQs, troubleshooting, Docker |
| 4 | +--- |
| 5 | + |
| 6 | +> ## Deprecation Notice :warning: |
| 7 | +> |
| 8 | +> Docker Toolbox is deprecated and is no longer in active development. Please use |
| 9 | +> [Docker Desktop](https://www.docker.com/products/docker-desktop) instead where |
| 10 | +> possible. |
| 11 | +
|
| 12 | +# title: Troubleshooting |
| 13 | + |
| 14 | +Typically, the QuickStart works out-of-the-box, but some scenarios can cause problems. |
| 15 | + |
| 16 | +## Example errors |
| 17 | + |
| 18 | +You might get errors when attempting to connect to a machine (such as with `docker-machine env default`) or pull an image from Docker Hub (as with `docker run hello-world`). |
| 19 | + |
| 20 | +The errors you get might be specific to certificates, like this: |
| 21 | + |
| 22 | + Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": dial tcp 192.168.99.100:2376: i/o timeout |
| 23 | + |
| 24 | +Others explicitly suggest regenerating certificates: |
| 25 | + |
| 26 | + Error checking TLS connection: Error checking and/or regenerating the certs: There was an error validating certificates for host "192.168.99.100:2376": x509: certificate is valid for 192.168.99.101, not 192.168.99.100 |
| 27 | + You can attempt to regenerate them using 'docker-machine regenerate-certs [name]'. |
| 28 | + Be advised that this will trigger a Docker daemon restart which will stop running containers. |
| 29 | + |
| 30 | +Or, indicate a network timeout, like this: |
| 31 | + |
| 32 | + bash-3.2$ docker run hello-world |
| 33 | + Unable to find image 'hello-world:latest' locally |
| 34 | + Pulling repository docker.io/library/hello-world |
| 35 | + Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images. You may want to check your internet connection or if you are behind a proxy. |
| 36 | + bash-3.2$ |
| 37 | + |
| 38 | +## Solutions |
| 39 | + |
| 40 | +Here are some quick solutions to help get back on track. These examples assume the Docker host is a machine called `default`. |
| 41 | + |
| 42 | +#### Regenerate certificates |
| 43 | + |
| 44 | +Some errors explicitly tell you to regenerate certificates. You might also try this for other errors that are certificate and/or connectivity related. |
| 45 | + |
| 46 | + $ docker-machine regenerate-certs default |
| 47 | + Regenerate TLS machine certs? Warning: this is irreversible. (y/n): y |
| 48 | + Regenerating TLS certificates |
| 49 | + |
| 50 | +#### Restart the Docker host |
| 51 | + |
| 52 | + $ docker-machine restart default |
| 53 | + |
| 54 | +After the machine starts, set the environment variables for the command window. |
| 55 | + |
| 56 | + $ eval $(docker-machine env default) |
| 57 | + |
| 58 | +Run `docker-machine ls` to verify that the machine is running and that this command window is configured to talk to it, as indicated by an asterisk for the active machine (__*__). |
| 59 | + |
| 60 | + $ docker-machine ls |
| 61 | + NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS |
| 62 | + default * virtualbox Running tcp://192.168.99.101:2376 v1.10.1 |
| 63 | + |
| 64 | +#### Stop the machine, remove it, and create a new one. |
| 65 | + |
| 66 | + $ docker-machine stop default |
| 67 | + Stopping "default"... |
| 68 | + Machine "default" was stopped. |
| 69 | + |
| 70 | + $ docker-machine rm default |
| 71 | + About to remove default |
| 72 | + Are you sure? (y/n): y |
| 73 | + Successfully removed default |
| 74 | + |
| 75 | +You can use the `docker-machine create` command with the `virtualbox` driver to create a new machine called `default` (or any name you want for the machine). |
| 76 | + |
| 77 | + $ docker-machine create --driver virtualbox default |
| 78 | + Running pre-create checks... |
| 79 | + (default) Default Boot2Docker ISO is out-of-date, downloading the latest release... |
| 80 | + (default) Latest release for github.com/boot2docker/boot2docker is v1.10.1 |
| 81 | + (default) Downloading |
| 82 | + ... |
| 83 | + Docker is up and running! |
| 84 | + To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env default |
| 85 | + |
| 86 | +Set the environment variables for the command window. |
| 87 | + |
| 88 | + $ eval $(docker-machine env default) |
| 89 | + |
| 90 | +Run `docker-machine ls` to verify that the new machine is running and that this command window is configured to talk to it, as indicated by an asterisk for the active machine (__*__). |
| 91 | + |
| 92 | +<a name="machine-http-proxy-solutions"></a> |
| 93 | + |
| 94 | +## HTTP proxies and connectivity errors |
| 95 | + |
| 96 | +A special brand of connectivity errors can be caused by HTTP proxy. If you install Docker Toolbox on a system using a virtual private network (VPN) that uses an HTTP proxy (such as a corporate network), you might encounter errors when the client attempts to connect to the server. |
| 97 | + |
| 98 | +Here are examples of this type of error: |
| 99 | + |
| 100 | + $ docker run hello-world |
| 101 | + An error occurred trying to connect: Post https://192.168.99.100:2376/v1.20/containers/create: Forbidden |
| 102 | + |
| 103 | + $ docker run ubuntu echo "hi" |
| 104 | + An error occurred trying to connect: Post https://192.168.99.100:2376/v1.20/containers/create: Forbidden |
| 105 | + |
| 106 | +### Configure HTTP proxy settings on Docker machines |
| 107 | + |
| 108 | +When Toolbox creates virtual machines (VMs) it runs `start.sh`, where it gets values for `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`, and passes them as `create` options to create the `default machine`. |
| 109 | + |
| 110 | +You can reconfigure HTTP proxy settings for private networks on already-created Docker machines, such as the `default` machine, then change the configuration when you are using the same system on a different network. |
| 111 | + |
| 112 | +Alternatively, you can modify proxy settings on your machine(s) manually through the configuration file at `/var/lib/boot2docker/profile` inside the VM, or configure proxy settings as a part of a `docker-machine create` command. |
| 113 | + |
| 114 | +Both solutions are described below. |
| 115 | + |
| 116 | +#### Update /var/lib/boot2docker/profile on the Docker machine |
| 117 | + |
| 118 | +One way to solve this problem is to update the file `/var/lib/boot2docker/profile` on an existing machine to specify the proxy settings you want. |
| 119 | + |
| 120 | +This file lives on the VM itself, so you need to `ssh` into the machine, then edit and save the file there. |
| 121 | + |
| 122 | +You can add your machine addresses as values for a `NO_PROXY` setting, and also specify proxy servers that you know about and you want to use. Typically setting your Docker machine URLs to `NO_PROXY` solves this type of connectivity problem, so that example is shown here. |
| 123 | + |
| 124 | +1. Use `ssh` to log in to the virtual machine. This example logs in to the |
| 125 | + `default` machine. |
| 126 | + |
| 127 | + $ docker-machine ssh default |
| 128 | + docker@default:~$ sudo vi /var/lib/boot2docker/profile |
| 129 | + |
| 130 | +2. Add a `NO_PROXY` setting to the end of the file similar to the example below. |
| 131 | + |
| 132 | + # replace with your office's proxy environment |
| 133 | + export "HTTP_PROXY=http://PROXY:PORT" |
| 134 | + export "HTTPS_PROXY=http://PROXY:PORT" |
| 135 | + # you can add more no_proxy with your environment. |
| 136 | + export "NO_PROXY=192.168.99.*,*.local,169.254/16,*.example.com,192.168.59.*" |
| 137 | + |
| 138 | +3. Restart Docker. |
| 139 | + |
| 140 | + After you modify the `profile` on your VM, restart Docker and log out of the machine. |
| 141 | + |
| 142 | + docker@default:~$ sudo /etc/init.d/docker restart |
| 143 | + docker@default:~$ exit |
| 144 | + |
| 145 | + Re-try Docker commands. Both Docker and Kitematic should run properly now. |
| 146 | + |
| 147 | + When you move to a different network (for example, leave the office's corporate network and return home), remove or comment out these proxy settings in `/var/lib/boot2docker/profile` and restart Docker. |
| 148 | + |
| 149 | +#### Create machines manually using --engine env to specify proxy settings |
| 150 | + |
| 151 | +Rather than reconfigure automatically-created machines, you can delete them and create your `default` machine and others manually with the `docker-machine create` command, using the `--engine env` flag to specify the proxy settings you want. |
| 152 | + |
| 153 | +Here is an example of creating a `default` machine with proxies set to `http://example.com:8080` and `https://example.com:8080`, and a `N0_PROXY` setting for the server `example2.com`. |
| 154 | + |
| 155 | + docker-machine create -d virtualbox \ |
| 156 | + --engine-env HTTP_PROXY=http://example.com:8080 \ |
| 157 | + --engine-env HTTPS_PROXY=https://example.com:8080 \ |
| 158 | + --engine-env NO_PROXY=example2.com \ |
| 159 | + default |
| 160 | + |
| 161 | + |
| 162 | +To learn more about using `docker-machine create`, see the [create](../../machine/reference/create.md) command in the [Docker Machine](../../machine/overview.md) reference. |
| 163 | + |
| 164 | + |
0 commit comments