简体   繁体   中英

Can't run executable that is in Path in Windows docker container

I am trying to run an executable from inside of a container from Power Shell and get an error message that it could not be found. However I've confirmed its directory is in Path and the executable is where I expect it to be. What am I missing?

PS C:\work\some_project> docker run -it --rm --name="iar_build" iar_env
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\docker_work> IarBuild.exe
IarBuild.exe : The term 'IarBuild.exe' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ IarBuild.exe
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (IarBuild.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\docker_work> $Env:Path
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\
OpenSSH\;C:\Users\ContainerAdministrator\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\IAR Systems\Embedded
 Workbench 8.1\common\bin"
PS C:\docker_work> ls 'C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\common\bin\IarBuild.exe'


    Directory: C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\common\bin


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         9/1/2018   4:09 AM         724992 IarBuild.exe


PS C:\docker_work>

My docker file contains the following:

...
# Add the IAR common\bin\ folder to the image's PATH
RUN setx path \
  "%path%;C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.1\common\bin\"
...
CMD [ "powershell.exe", "-executionpolicy" , "Unrestricted" ]

You will need to add a.\ so it will look like.\IarBuild.exe as it is currently trying to process the.exe as a cmdlet

Edit: If you start to type the name of the exe and press Tab it will autocomplete to.\IarBuild.exe if not type in manually

Hope that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM