2016-08-02 01:57:15 -04:00
|
|
|
# Troubleshooting the GitLab Container Registry
|
|
|
|
|
|
|
|
## Basic Troubleshooting
|
|
|
|
|
|
|
|
1. Check to make sure that the system clock on your Docker client and GitLab server have
|
|
|
|
been synchronized (e.g. via NTP).
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
2. If you are using an S3-backed Registry, double check that the IAM
|
2016-08-02 01:57:15 -04:00
|
|
|
permissions and the S3 credentials (including region) are correct. See [the
|
|
|
|
sample IAM policy](https://docs.docker.com/registry/storage-drivers/s3/)
|
|
|
|
for more details.
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
3. Check the Registry logs (e.g. `/var/log/gitlab/registry/current`) and the GitLab production logs
|
2016-08-02 01:57:15 -04:00
|
|
|
for errors (e.g. `/var/log/gitlab/gitlab-rails/production.log`). You may be able to find clues
|
|
|
|
there.
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
## Advanced Troubleshooting
|
2016-08-02 01:57:15 -04:00
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
>**NOTE:** The following section is only recommended for experts.
|
2016-08-02 01:57:15 -04:00
|
|
|
|
|
|
|
Sometimes it's not obvious what is wrong, and you may need to dive deeper into
|
2016-08-03 10:33:37 -04:00
|
|
|
the communication between the Docker client and the Registry to find out
|
2016-08-02 01:57:15 -04:00
|
|
|
what's wrong. We will use a concrete example in the past to illustrate how to
|
|
|
|
diagnose a problem with the S3 setup.
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
### Unexpected 403 error during push
|
2016-08-02 01:57:15 -04:00
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
A user attempted to enable an S3-backed Registry. The `docker login` step went
|
2016-08-02 01:57:15 -04:00
|
|
|
fine. However, when pushing an image, the output showed:
|
|
|
|
|
|
|
|
```
|
|
|
|
The push refers to a repository [s3-testing.myregistry.com:4567/root/docker-test]
|
|
|
|
dc5e59c14160: Pushing [==================================================>] 14.85 kB
|
|
|
|
03c20c1a019a: Pushing [==================================================>] 2.048 kB
|
|
|
|
a08f14ef632e: Pushing [==================================================>] 2.048 kB
|
|
|
|
228950524c88: Pushing 2.048 kB
|
|
|
|
6a8ecde4cc03: Pushing [==> ] 9.901 MB/205.7 MB
|
|
|
|
5f70bf18a086: Pushing 1.024 kB
|
|
|
|
737f40e80b7f: Waiting
|
|
|
|
82b57dbc5385: Waiting
|
|
|
|
19429b698a22: Waiting
|
|
|
|
9436069b92a3: Waiting
|
|
|
|
error parsing HTTP 403 response body: unexpected end of JSON input: ""
|
|
|
|
```
|
|
|
|
|
2016-08-02 18:24:15 -04:00
|
|
|
This error is ambiguous, as it's not clear whether the 403 is coming from the
|
2016-08-03 10:33:37 -04:00
|
|
|
GitLab Rails application, the Docker Registry, or something else. In this
|
2016-08-02 18:24:15 -04:00
|
|
|
case, since we know that since the login succeeded, we probably need to look
|
2016-08-03 10:33:37 -04:00
|
|
|
at the communication between the client and the Registry.
|
2016-08-02 01:57:15 -04:00
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
The REST API between the Docker client and Registry is [described
|
2016-08-02 01:57:15 -04:00
|
|
|
here](https://docs.docker.com/registry/spec/api/). Normally, one would just
|
|
|
|
use Wireshark or tcpdump to capture the traffic and see where things went
|
|
|
|
wrong. However, since all communication between Docker clients and servers
|
|
|
|
are done over HTTPS, it's a bit difficult to decrypt the traffic quickly even
|
|
|
|
if you know the private key. What can we do instead?
|
|
|
|
|
2016-08-02 18:20:36 -04:00
|
|
|
One way would be to disable HTTPS by setting up an [insecure
|
2016-08-03 10:33:37 -04:00
|
|
|
Registry](https://docs.docker.com/registry/insecure/). This could introduce a
|
2016-08-02 18:20:36 -04:00
|
|
|
security hole and is only recommended for local testing. If you have a
|
|
|
|
production system and can't or don't want to do this, there is another way:
|
|
|
|
use mitmproxy, which stands for Man-in-the-Middle Proxy.
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
### mitmproxy
|
2016-08-02 01:57:15 -04:00
|
|
|
|
2016-08-02 18:20:36 -04:00
|
|
|
[mitmproxy](https://mitmproxy.org/) allows you to place a proxy between your
|
|
|
|
client and server to inspect all traffic. One wrinkle is that your system
|
|
|
|
needs to trust the mitmproxy SSL certificates for this to work.
|
2016-08-02 01:57:15 -04:00
|
|
|
|
|
|
|
The following installation instructions assume you are running Ubuntu:
|
|
|
|
|
|
|
|
1. Install mitmproxy (see http://docs.mitmproxy.org/en/stable/install.html)
|
2016-08-03 10:33:37 -04:00
|
|
|
1. Run `mitmproxy --port 9000` to generate its certificates.
|
|
|
|
Enter <kbd>CTRL</kbd>-<kbd>C</kbd> to quit.
|
|
|
|
1. Install the certificate from `~/.mitmproxy` to your system:
|
2016-08-02 01:57:15 -04:00
|
|
|
|
|
|
|
```sh
|
|
|
|
sudo cp ~/.mitmproxy/mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/mitmproxy-ca-cert.crt
|
|
|
|
sudo update-ca-certificates
|
|
|
|
```
|
|
|
|
|
|
|
|
If successful, the output should indicate that a certificate was added:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
Updating certificates in /etc/ssl/certs... 1 added, 0 removed; done.
|
|
|
|
Running hooks in /etc/ca-certificates/update.d....done.
|
|
|
|
```
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
To verify that the certificates are properly installed, run:
|
2016-08-02 01:57:15 -04:00
|
|
|
|
|
|
|
```sh
|
|
|
|
mitmproxy --port 9000
|
|
|
|
```
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
This will run mitmproxy on port `9000`. In another window, run:
|
2016-08-02 01:57:15 -04:00
|
|
|
|
|
|
|
```sh
|
|
|
|
curl --proxy http://localhost:9000 https://httpbin.org/status/200
|
|
|
|
```
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
If everything is setup correctly, you will see information on the mitmproxy window and
|
2016-08-02 01:57:15 -04:00
|
|
|
no errors from the curl commands.
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
### Running the Docker daemon with a proxy
|
2016-08-02 01:57:15 -04:00
|
|
|
|
|
|
|
For Docker to connect through a proxy, you must start the Docker daemon with the
|
|
|
|
proper environment variables. The easiest way is to shutdown Docker (e.g. `sudo initctl stop docker`)
|
|
|
|
and then run Docker by hand. As root, run:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
export HTTP_PROXY="http://localhost:9000"
|
|
|
|
export HTTPS_PROXY="https://localhost:9000"
|
|
|
|
docker daemon --debug
|
|
|
|
```
|
|
|
|
|
|
|
|
This will launch the Docker daemon and proxy all connections through mitmproxy.
|
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
### Running the Docker client
|
2016-08-02 01:57:15 -04:00
|
|
|
|
2016-08-03 10:33:37 -04:00
|
|
|
Now that we have mitmproxy and Docker running, we can attempt to login and push
|
|
|
|
a container image. You may need to run as root to do this. For example:
|
2016-08-02 01:57:15 -04:00
|
|
|
|
|
|
|
```sh
|
|
|
|
docker login s3-testing.myregistry.com:4567
|
|
|
|
docker push s3-testing.myregistry.com:4567/root/docker-test
|
|
|
|
```
|
|
|
|
|
|
|
|
In the example above, we see the following trace on the mitmproxy window:
|
|
|
|
|
|
|
|
![mitmproxy output from Docker](img/mitmproxy-docker.png)
|
|
|
|
|
|
|
|
The above image shows:
|
|
|
|
|
|
|
|
* The initial PUT requests went through fine with a 201 status code.
|
|
|
|
* The 201 redirected the client to the S3 bucket.
|
|
|
|
* The HEAD request to the AWS bucket reported a 403 Unauthorized.
|
|
|
|
|
|
|
|
What does this mean? This strongly suggests that the S3 user does not have the right
|
|
|
|
[permissions to perform a HEAD request](http://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectHEAD.html).
|
|
|
|
The solution: check the [IAM permissions again](https://docs.docker.com/registry/storage-drivers/s3/).
|
2016-08-03 10:33:37 -04:00
|
|
|
Once the right permissions were set, the error will go away.
|