Created
February 9, 2020 17:55
-
-
Save awakecoding/f24608fad3ed6e867df624cef62e28ce to your computer and use it in GitHub Desktop.
Simple script to reproduce remaining WiredTiger.lock lock file issue observed with MongoDB Windows container: https://github.com/docker-library/mongo/issues/385
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple script to reproduce remaining WiredTiger.lock | |
# lock file issue observed with MongoDB Windows container: | |
# https://github.com/docker-library/mongo/issues/385 | |
function Remove-MongoLock | |
{ | |
param( | |
[string] $VolumeName | |
) | |
$Volume = $(docker volume inspect $VolumeName) | ConvertFrom-Json | |
$WiredTigerLock = Join-Path $Volume.MountPoint 'WiredTiger.lock' | |
if (Test-Path $WiredTigerLock) { | |
Write-Host "Found remaining WiredTiger.lock file" | |
Write-Warning "Removing $WiredTigerLock" | |
Remove-Item $WiredTigerLock -Force | |
} else { | |
Write-Host "No remaining WiredTiger.lock file found" | |
} | |
} | |
function Invoke-Docker | |
{ | |
param( | |
[Parameter(Position=0)] | |
[string[]] $Arguments | |
) | |
$Command = (@('docker') + $Arguments) -Join " " | |
Write-Host $Command | |
Invoke-Expression $Command | |
} | |
function Test-MongoLock | |
{ | |
$VolumeName = 'mongo-data' | |
$ContainerName = 'mongo-test' | |
$ContainerImage = "library/mongo:4.2-windowsservercore-1809" | |
Invoke-Docker @('pull', $ContainerImage) | |
Invoke-Docker @('volume', 'create', $VolumeName) | |
Invoke-Docker @('run', '--name', $ContainerName, '-d', '-v', "$VolumeName`:c:\data\db", $ContainerImage) | |
Start-Sleep -Seconds 3 | |
Invoke-Docker @('stop', $ContainerName) | |
Invoke-Docker @('rm', $ContainerName) | |
Remove-MongoLock -VolumeName:$VolumeName | |
Invoke-Docker @('volume', 'rm', $VolumeName) | |
} | |
Test-MongoLock |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment