StefanScherer / windows-docker-machine

Work with Windows containers and LCOW on Mac/Linux/Windows

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

'docker context ls' does not show '2019-box'

EthanDavis opened this issue · comments

Hello,

I am unable to see the docker context after running
vagrant up --provider virtualbox 2019-box
I referenced a closed issue (#65) and tried the fix that was proposed there vagrant provision 2019-box but I still don't see the context.

I see the 2019-box running in virtual machine and if I run commands from which the virtual machine I see the context but I don't from my mac terminal.

The first time I ran it worked but subsequent times I get the following output.

Bringing machine '2019-box' up with 'virtualbox' provider...
==> 2019-box: Checking if box 'StefanScherer/windows_2019_docker' version '2021.05.15' is up to date...
==> 2019-box: Clearing any previously set forwarded ports...
==> 2019-box: Clearing any previously set network interfaces...
==> 2019-box: Preparing network interfaces based on configuration...
    2019-box: Adapter 1: nat
    2019-box: Adapter 2: hostonly
==> 2019-box: Forwarding ports...
    2019-box: 3389 (guest) => 3389 (host) (adapter 1)
    2019-box: 5985 (guest) => 55985 (host) (adapter 1)
    2019-box: 5986 (guest) => 55986 (host) (adapter 1)
    2019-box: 22 (guest) => 2222 (host) (adapter 1)
==> 2019-box: Running 'pre-boot' VM customizations...
==> 2019-box: Booting VM...
==> 2019-box: Waiting for machine to boot. This may take a few minutes...
    2019-box: WinRM address: 127.0.0.1:55985
    2019-box: WinRM username: vagrant
    2019-box: WinRM execution_time_limit: PT2H
    2019-box: WinRM transport: negotiate
==> 2019-box: Machine booted and ready!
==> 2019-box: Checking for guest additions in VM...
    2019-box: The guest additions on this VM do not match the installed version of
    2019-box: VirtualBox! In most cases this is fine, but in rare cases it can
    2019-box: prevent things such as shared folders from working properly. If you see
    2019-box: shared folder errors, please make sure the guest additions within the
    2019-box: virtual machine match the version of VirtualBox you have installed on
    2019-box: your host and reload your VM.
    2019-box: 
    2019-box: Guest Additions Version: 6.1.22
    2019-box: VirtualBox Version: 7.0
==> 2019-box: Configuring and enabling network interfaces...
==> 2019-box: Mounting shared folders...
    2019-box: /Users/ethandavis => /Users/ethandavis
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

function Test-ReparsePoint([string]$path) {
  $file = Get-Item $path -Force -ea 0
  return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}

$MountPoint = [System.IO.Path]::GetFullPath("/Users/ethandavis")
$ShareName = "Users_ethandavis"
$VmProviderUncPath = "\\vboxsvr\Users_ethandavis"

# https://github.com/BIAINC/vagrant-windows/issues/4
# Not sure why this works, but it does.

& net use $ShareName 2>&1 | Out-Null

Write-Debug "Attempting to mount $ShareName to $MountPoint"
if( (Test-Path "$MountPoint") -and (Test-ReparsePoint "$MountPoint") )
{
  Write-Debug "Junction already exists, so I will delete it"
  # Powershell refuses to delete junctions, oh well use cmd
  cmd.exe /c rd "$MountPoint"

  if ( $LASTEXITCODE -ne 0 )
  {
    Write-Error "Failed to delete symbolic link at $MountPoint"
    exit 1
  }

}
elseif(Test-Path $MountPoint)
{
  Write-Error "Mount point already exists and is not a symbolic link"
  exit 1
}

$BaseDirectory = [System.IO.Path]::GetDirectoryName($MountPoint)

if (-not (Test-Path $BaseDirectory))
{
  Write-Debug "Creating parent directory for mount point $BaseDirectory"
  New-Item $BaseDirectory -Type Directory -Force | Out-Null
}

cmd.exe /c mklink /D "$MountPoint" "$VmProviderUncPath" | out-null

if ( $LASTEXITCODE -ne 0 )
{
  exit 1
}


Stdout from the command:



Stderr from the command:

function Test-ReparsePoint([string]$path) {
 : Mount point already exists and is not a symbolic link
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException

If I start it from the VirtualBox UI it starts correctly.

vagrant provision 2019-box output

==> 2019-box: Running provisioner: shell...
    2019-box: Running: scripts/create-machine.ps1 as C:\tmp\vagrant-shell.ps1
    2019-box: 
    2019-box: === Generating CA
    2019-box: 
    2019-box: === Generating CA public key
    2019-box: 
    2019-box: === Generating Server certificate
    2019-box: 
    2019-box: === Generating Server private key
    2019-box: 
    2019-box: === Generating Client certificate
    2019-box: 
    2019-box: === Generating Client key
    2019-box: 
    2019-box: === Creating / Updating C:\ProgramData\docker\config\daemon.json
    2019-box: 
    2019-box: === Creating / Updating C:\Users\vagrant\.docker\machine\machines\2019-box\config.json
    2019-box: 
    2019-box: === Copying Client certificates to C:\Users\vagrant\.docker\machine\machines\2019-box
    2019-box: 
    2019-box: === Copying Docker Machine configuration to C:/Users/ethandavis\.docker\machine\machines\2019-box
    2019-box: 
    2019-box: === Creating / Updating
    2019-box: 
    2019-box: === Copying Client certificates to C:\Users\vagrant\.docker\contexts\tls\626f71594ecefa7e7eaa6b2e89fe7cf815380f3168cf4c1db0cae5f4317a444e\docker
    2019-box: 
    2019-box: === Copying Docker Context configuration to C:/Users/ethandavis\.docker\contexts\meta\626f71594ecefa7e7eaa6b2e89fe7cf815380f3168cf4c1db0cae5f4317a444e
    2019-box: Restarting Docker
    2019-box: Opening Docker TLS port
    2019-box: Ok.
    2019-box: 

Let me know if I can provide more details.

MacOS Monterey 12.6.6
Docker 24.0.2
Vagrant 2.3.4
Virtualbox 7.0.8r156879

Any and all help would be appreciated!

After removing the virtual box and re-setting it up things are working as expected