Navcontainerhelper: Copying the file to running NAV Container on Windows 10 fails with "filesystem operations against a running Hyper-V container are not supported"

Created on 6 Dec 2017  路  8Comments  路  Source: microsoft/navcontainerhelper

Environment: Windows 10 and navcontainerhelper 0.2.1.3
Action: Running Import-ObjectsToNavContainer -containerName MyContainer -objectsFile "C:\WorkingFolder\MyFOB.fob"

Error: _Error response from daemon: filesystem operations against a running Hyper-V container are not supported_

This seems to be caused by the issue described e.g. here: https://stackoverflow.com/questions/45654570/unable-to-copy-to-windows-container-docker-cp-in-windows-10

The suggested workaround for running container on Windows 10 might be to change the Copy-FileToNavContainer command to make it two steps:

  1. Use one of the mapped folders and copy the file(s) to the mapped folder
  2. Enter PS Session and copy it from the mapped folder to the destination directory
bug

All 8 comments

Yes, that's actually true. You can't copy files into the containers being running.

Of course, your proposal is valid and very logical (there is at least one mapped folder in the most scenarios). I have another idea but the my one is really a very alternative one (I can't even test it right now as I am on vacation and don't have my laptop with me just now). It probably could work for small files but for a big FOB...??? The idea is pass the file content using docker exec ('fob content' | Set-Content target_filename).

Thanks, I will probably remove Copy-FileToNavContainer and Copy-FileFromNavContainer and then handle this in the 3 places where they are used. In these situations, I have all shared folders and can just use one of these very very easily (instead of using c:\run in the container).
Didn't think of it as the copy functions works fine on Windows Server 2016.

BTW - This one works like a charm (tested on Win10, WinServer 2016):

$ContSession = New-PSSession -ContainerId $cid -RunAsAdministrator
Copy-Item -Path [your_local_file] -Destination [in_container_destination_path] -ToSession $ContSession

The solution doesn't dependent on a mapped folder (docker volumes).

Wow - thanks Jakub - I will definitely use that.

    $id = Get-NavContainerId -containerName $containerName 

    $session = New-PSSession -ContainerId $id -RunAsAdministrator -ErrorAction Ignore
    if ($session) {
        Copy-Item -Path $localPath -Destination $containerPath -ToSession $session
        Remove-PSSession -Session $session
    } else {
        docker cp $localPath ${id}:$containerPath
    }

Checked in, will be included in the next gallery update

Was this page helpful?
0 / 5 - 0 ratings