# This script will create docker volumes in the specified path and inspect them after creation
# Define an array of volume names
$Volumes = @("jenkins", "webapps", "gitea", "giteasql")
# Define the path where the volumes will be created
$PathToVolumes = "C:\Dev\docker\volumes\"
# Define the docker command to create volumes
# The --opt type=none option specifies a non-docker managed volume
# The --opt o=bind option binds the volume to a directory on the host machine
# The --opt device=$PathToVolumes option specifies the directory on the host machine where the volume will be created
$dockercmd = "docker volume create --opt type=none --opt o=bind --opt device=$PathToVolumes"
# Loop through each volume name in the array
$Volumes | ForEach-Object {
# Create a full command by concatenating the docker command with the volume name
$fullcmd = $dockercmd + $_ + ' ' + $_
# Execute the full command using Invoke-Expression
# This will create the volume with the specified name and bind it to the specified directory on the host machine
Invoke-Expression $fullcmd
# Execute the docker command to inspect the volume with the specified name
# This will display information about the volume, such as its driver, name, and mount point
Invoke-Expression "docker volume inspect $($_)"
}
Comments
0 B
|👍
/👎
0 B
|👍
/👎