|
@@ -1,31 +1,53 @@
|
1
|
1
|
# clean_registry
|
2
|
2
|
Clean the Docker Registry by removing untagged repositories and running the garbage collector in Docker Registry >= 2.4.0
|
3
|
3
|
|
4
|
|
-The optional `-x` flag may be used to remove the specified repositories or tagged images.
|
|
4
|
+The optional ``-x`` flag may be used to remove the specified repositories or tagged images.
|
5
|
5
|
|
6
|
|
-NOTES:
|
7
|
|
- - This script stops the Registry container during cleanup to prevent corruption, making it temporarily unavailable to clients.
|
8
|
|
- - This script assumes the [filesystem](https://github.com/docker/distribution/blob/master/docs/configuration.md#storage) storage driver.
|
9
|
|
- - This script may run stand-alone (on local setups) or dockerized (which supports both local and remote Docker setups). To run stand-alone, you must install **docker-py** and **pyyaml** with:
|
10
|
|
-
|
11
|
|
- `pip3 install docker pyyaml`
|
12
|
|
-
|
13
|
|
-## Usage:
|
|
6
|
+# WARNING:
|
|
7
|
+
|
|
8
|
+Make backups of target docker-registry/containers/tags to avoid loosing data.
|
|
9
|
+
|
|
10
|
+This script stops the Registry container during cleanup to prevent corruption, making it temporarily unavailable to clients.
|
|
11
|
+
|
|
12
|
+This script assumes the [filesystem](https://github.com/docker/distribution/blob/master/docs/configuration.md#storage) storage driver.
|
|
13
|
+
|
|
14
|
+## Running standalone
|
|
15
|
+
|
|
16
|
+This script may be run as stand-alone (on local setups) or dockerized (which supports both local and remote Docker setups). To run stand-alone, the best is to run in virtualenv and install required packages via pip:
|
|
17
|
+
|
|
18
|
+```bash
|
|
19
|
+virtualenv --python=python3 .venv
|
|
20
|
+. .venv/bin/activate
|
|
21
|
+pip3 install --upgrade pip
|
|
22
|
+pip3 install -r requirements.txt
|
|
23
|
+```
|
|
24
|
+
|
|
25
|
+You may need to execute above commands as privileged user to access docker service (sudo + activate virtualenv).
|
|
26
|
+
|
|
27
|
+## Usage
|
14
|
28
|
|
15
|
29
|
```
|
16
|
30
|
clean_registry.py [OPTIONS] CONTAINER [REPOSITORY[:TAG]]...
|
17
|
31
|
Options:
|
18
|
32
|
-x, --remove Remove the specified images or repositories.
|
19
|
|
- -q, --quiet Supress non-error messages.
|
|
33
|
+ -q, --quiet Suppress non-error messages.
|
20
|
34
|
-V, --version Show version and exit.
|
21
|
35
|
```
|
22
|
36
|
|
23
|
37
|
## Docker usage with local Docker setup
|
24
|
38
|
|
25
|
|
-`docker run --rm --volumes-from CONTAINER -v /var/run/docker.sock:/var/run/docker.sock ricardobranco/clean_registry [OPTIONS] CONTAINER [REPOSITORY[:TAG]]...`
|
|
39
|
+```bash
|
|
40
|
+docker run --rm --volumes-from CONTAINER -v /var/run/docker.sock:/var/run/docker.sock ricardobranco/clean_registry [OPTIONS] CONTAINER [REPOSITORY[:TAG]] ...
|
|
41
|
+```
|
|
42
|
+
|
|
43
|
+## Docker usage with remote Docker setup
|
|
44
|
+
|
|
45
|
+Make sure to read about [remote Docker setup](https://docs.docker.com/engine/security/https/#secure-by-default).
|
26
|
46
|
|
27
|
|
-## Docker usage with [remote Docker setup](https://docs.docker.com/engine/security/https/#secure-by-default)
|
|
47
|
+```bash
|
|
48
|
+docker run --rm --volumes-from CONTAINER -e DOCKER_HOST -e DOCKER_TLS_VERIFY=1 -v /root/.docker:/root/.docker ricardobranco/clean_registry [OPTIONS] CONTAINER [REPOSITORY[:TAG]]...
|
|
49
|
+```
|
28
|
50
|
|
29
|
|
-`docker run --rm --volumes-from CONTAINER -e DOCKER_HOST -e DOCKER_TLS_VERIFY=1 -v /root/.docker:/root/.docker ricardobranco/clean_registry [OPTIONS] CONTAINER [REPOSITORY[:TAG]]...`
|
|
51
|
+Note:
|
30
|
52
|
|
31
|
|
-Note: Paths other than `/root/.docker` path may be specified with the **DOCKER_CERT_PATH** environment variable. In any case, your `~/.docker/*.pem` files should be in the server to be able to run as a client against itself.
|
|
53
|
+Paths other than ``/root/.docker`` path may be specified with the ``**DOCKER_CERT_PATH**`` environment variable. In any case, your ``~/.docker/*.pem`` files should be in the server to be able to run as a client against itself.
|