-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDockerTasks.ps1
More file actions
42 lines (34 loc) · 918 Bytes
/
DockerTasks.ps1
File metadata and controls
42 lines (34 loc) · 918 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# PowerShell script to replicate Makefile functionality on Windows
# USAGE: .\DockerTasks.ps1 -Task <function_name in COMMANDS>
# Main execution logic
param (
[Parameter(Mandatory=$true)]
[ValidateSet("docker_gen", "docker_clean_images", "docker_clean_volumes")]
$Task
)
# COMMANDS
function docker_gen {
# Start Docker Compose in detached mode
docker-compose up -d
}
function docker_clean_images {
# Stop all containers
docker-compose down
# Remove all images
docker images -q| ForEach-Object {
docker rmi -f $_
}
}
function docker_clean_volumes {
# Stop all containers
docker-compose down
# Remove all Docker volumes
docker volume ls -q | ForEach-Object {
docker volume rm $_
}
}
switch ($Task) {
"docker_gen" { docker_gen }
"docker_clean_images" { docker_clean_images }
"docker_clean_volumes" { docker_clean_volumes }
}