Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I resolve the error oci runtime error: exec: no such file or directory when using docker run on Windows

Tags:

docker

windows

When running a Docker command such as

docker run ubuntu /bin/echo 'Hello world'

used in the in the starter example docs on the Learn by Example page of the Docker docs I see the error

C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: oci runtime error: exec: "C:/Program Files/Git/usr/bin/bash": stat C:/Program Files/Git/usr/bin/bash: no such file or directory.

How can I resolve this?

like image 440
SnapShot Avatar asked Dec 08 '22 21:12

SnapShot


1 Answers

This error could be caused by the setup on your system including mingw (you might see this if you have installed Git for Windows with MSYS2 for example - see here for more information). The path is being converted - to stop this you can use a double slash // before the command. In this example you can use

docker run ubuntu //bin/echo 'Hello world'

(notice the double slash (//) above). If all goes well you should now see

Hello world

An complete and slightly more complex example is starting an Ubuntu interactive shell

 docker run -it -v /$(pwd)/app:/root/app ubuntu //bin/bash

Note that in my case using Git Bash I only needed one extra slash because echo $(pwd) on my machine expands to:

/c/Users/UserName/path/to/volume/mount

As another example the following can be used if zip is not available (as is the case on Windows 10 as well as Git Bash) You cannot easily zip a file for a something like an AWS Lambda function (actually there are few ways without Docker or even installing third party software if you prefer). If you want to zip the app folder under your current directory use this:

 docker run -it -v /$(pwd)/app:/root/app mydockeraccount/dockerimagewithzip //usr/bin/zip -r //root/app/test1.zip //root/app 

The mydockeraccount/dockerimageqithzip can be build by creating a Dockerfile like this:

FROM ubuntu
RUN apt-get update && apt-get install -y zip

Then run:

docker build -t mydockeraccount/dockerimagewithzip .
like image 93
SnapShot Avatar answered Dec 11 '22 11:12

SnapShot