https://github.com/hectorm/docker-bulk
Perform bulk actions on Docker resources.
https://github.com/hectorm/docker-bulk
Last synced: over 1 year ago
JSON representation
Perform bulk actions on Docker resources.
- Host: GitHub
- URL: https://github.com/hectorm/docker-bulk
- Owner: hectorm
- License: mit
- Created: 2023-02-12T15:01:52.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-07-20T15:55:06.000Z (about 2 years ago)
- Last Synced: 2025-02-21T00:11:10.427Z (over 1 year ago)
- Language: Shell
- Homepage:
- Size: 6.84 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# docker bulk
Perform bulk actions on Docker resources.
## Installation
### Requirements
* [`jq`](https://stedolan.github.io/jq/) `1.6+`
### Current user
```sh
[ -n "$DOCKER_CONFIG" ] || export DOCKER_CONFIG="$HOME"/.docker; mkdir -p "$DOCKER_CONFIG"/cli-plugins
curl --proto '=https' --tlsv1.3 -o "$DOCKER_CONFIG"/cli-plugins/docker-bulk 'https://raw.githubusercontent.com/hectorm/docker-bulk/v0.0.1/docker-bulk'
chmod +x "$DOCKER_CONFIG"/cli-plugins/docker-bulk
```
### System-wide
```sh
sudo mkdir -p /usr/local/lib/docker/cli-plugins
sudo curl --proto '=https' --tlsv1.3 -o /usr/local/lib/docker/cli-plugins/docker-bulk 'https://raw.githubusercontent.com/hectorm/docker-bulk/v0.0.1/docker-bulk'
sudo chmod +x /usr/local/lib/docker/cli-plugins/docker-bulk
```
## Usage
```sh
docker bulk RESOURCE FILTER [COMMAND]
```
The command is executed with the resource ID as the last argument. If the command is omitted, the resource ID is printed.
> **Note**
> `jq` is used to perform the filtering on the JSON specification of the resource, please refer to its [manual](https://stedolan.github.io/jq/manual/) to learn more about the filter syntax.
### Examples
#### Restart unhealthy containers:
```sh
docker bulk container '.State.Status == "running" and .State.Health.Status == "unhealthy"' docker container restart
```
#### Restart containers that have the Docker daemon socket mounted:
```sh
docker bulk container '.Mounts[].Source == "/var/run/docker.sock"' docker container restart
```
#### Remove volumes with the prefix `test_` in their name:
```sh
docker bulk volume '.Name | startswith("test_")' docker volume rm
```
#### List all images:
```sh
docker bulk image '.'
```
#### List images bigger than 500 MB:
```sh
docker bulk image '.Size > 500 * $MB'
```
#### List images older than 7 days:
```sh
docker bulk image '.Created | sub("[.][0-9]+Z$"; "Z") | fromdate < now - 7 * $DAY'
```
#### List IPv6 capable networks with the `bridge` driver:
```sh
docker bulk network '.EnableIPv6 == true and .Driver == "bridge"'
```