How can I resolve the error oci runtime error: exec: no such file or directory when using docker run on Windows - 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?

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 .

Related

Docker compose V2: unknown shorthand flag 'f' (windows)

I'm currently running docker desktop version 20.10.22 (build 3a2c30b, fresh install) on Windows (using wsl2), but docker compose commands with the -f flag do not work correctly. Since I'm using docker compose V2 (checked the option in the docker desktop settings), my commands are with a space instead of a hyphen. I get the following message when running any docker compose command using -f:
unknown shorthand flag: 'f' in -f See 'docker --help'.
Specifically, I'm running the FIWARE NGSI-LD tutorials. All docker compose commands that are used within those tutorials fail. The commands can be found in the services file for each tutorial. For example, a command that fails (saying that the -f flag does not exist) within the Short-Term-History tutorial is the following:
docker compose -f docker-compose/mintaka.yml -p fiware up -d --remove-orphans --renew-anon-volumes
The weird thing is that docker compose --help and docker compose --version both return the output from respectively docker --help and docker --version, as if it excludes the compose keyword. The output of the above command also refers to the standard docker help command instead of the docker compose help.
UPDATE: Docker excludes the compose keyword between docker and the rest of the command. Replacing compose with a random string of letters gives the same effect. It seems as if it cannot recognize the compose keyword.
The old docker-compose is not installed so that does not work either. Running which docker-compose returns the docker-compose.exe location, inside the .../Docker/resources/bin folder. Running which docker compose returns the location of docker.exe. The .../Docker/resources/bin folder is inside the path environment variable.
Does anybody know what the problem might be? I've searched countless websites but did not find any solutions for this problem yet.
Kind regards
Here is what I have in running processes when I run docker compose events:
Please check if you have all these directories and files. Then we can troubleshoot further.
I reinstalled docker desktop with the same installer (also same version) and this resolved the problem weirdly enough...
The only difference between my old and new installation was that I already had wsl2 installed this time.

CircleCI 2.0 -> /bin/bash: bash: command not found

In circle CI build I am trying to install nvm as follows:
- run:
name: Install nvm
command: curl -o-https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
But I am getting this error:
How do fix this issue?
Disclaimer: Developer Advocate at CircleCI
You didn't specify which Docker image (or executor) you are using. Most likely you're using a Docker image that doesn't include Bash. You can do one of three things:
Install Bash first in that Docker image.
Choose a Docker image with Bash already installed.
Use sh for the command instead of Bash.
Option 3 is the easiest option as long as the install script isn't using Bash specific features. You can try it by replacing the end of the command like this:
curl -o-https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | sh

Run a docker image on Windows results in "oci runtime error: exec: "bash": executable file not found in $PATH."

I'm running Docker on Windows ("Docker Toolbox", not "Docker for Windows").
I've built an image with a rails app inside. It works properly on my Mac OS but stucks on production on Windows.
Using Docker 1.12 and docker-machine 0.8.0 on both machines.
When I create a machine and try to run the container from image, I do:
docker run -it myRepo:myTag bash
which opens me a interactive terminal on Mac OS, but Windows 7 and Windows Server 2011 are both responding with:
"Error response from daemon: oci runtime error: exec: "bash":
executable file not found in $PATH."
I use the MINGW64 shell via the Docker Quickstart Terminal but the old cmd.exe returns the same.
Can anybody help me with this issue? I've tried several hours to find a solution but there are too few answers for Windows.
Thank you in advance!
I also use Windows 7 with MINGW64. Here is what I get using nginx as example:
$docker run -it nginx bash
cannot enable tty mode on non tty input
I don't think you can open a tty using MINGW64.
You can try:
$docker run -i nginx bash
ls
bin
...
You will so no prompt or any indication you are inside the container. Just run ls and it should work inside your container.
Another option is to try to use winpty for the tty:
$ winpty docker run -it myRepo:myTag bash
root#644f59e6f818:/#
Have you tried?
$ winpty docker run -it myRepo:myTag /bin/bash
I haven't got the problem you are mentioning but I have seen it before when I was mapping volumes.
If you are mapping volumes using MINGW64, you will need to add an extra / before the local mapping. For example:
docker run -p 8080:80 -v "/$PWD":/var/share/nginx/html nginx
Let me know your findings.

Docker unable to process Dockerfile

I trying to create Dockerfile file from scratch on Windows7. However, currently have trouble on very first step. My Dockerfile is placed under C:\Users\Arturas\Docker\Jenkins. Virtual Box shared folder path on c:\Users and folder name on c/Users (defaults from boot2docker was not changed).
When I run (on git bash):
$ docker build --file Docker/Jenkins/ .
I get:
unable to process Dockerfile: read C:\Users\Arturas\Docker\Jenkins:
The handle is invalid.
Dockerfile content is just one line:
FROM jenkins
I just started learning Docker so my experience is very limited yet. However from tools like boot2docker I expect basic commands to work out of the box so I must be missing something.
Try instead:
cd /C/Users/Arturas/Docker/Jenkins
docker build -t myimage .
I assume here that you have a file named Dockerfile under the Jenkins folder.
The -f option of a docker build is for referencing the Dockerfile (if it is named differently for instance)
Don't forget to use the latest docker-machine (the 0.5.4 one: an auto-extractible exe docker-machine_windows-amd64.exe): it uses a VM named boot2docker.iso through VirtualBox.
Try to specify the "Dockerfile" name
$ docker build --file Docker/Jenkins/Dockerfile .

'docker run -v' does not work on Windows using Docker Toolbox

When running the following command from a CoreOS VM, it works as expected:
docker run --rm -v $PWD:/data composer init
It will initialize the composer.json file in the current working directory by using the Docker volume mapping as specified. The Docker container basically has the PHP tool composer installed and will run that tool inside the /data folder of the container. By using the mapping it actually applies it on the files on the host machine.
However when trying to run this command on Windows using Docker Toolbox I get the following error.
$ docker run --rm -v $PWD:/data composer --help
invalid value "C:\\Users\\Marco;C:\\Program Files\\Git\\data" for flag -v: bad mount mode specified : \Program Files\Git\data
See 'C:\ProgramData\Chocolatey\lib\docker\bin\docker.exe run --help'.
What I notice here is although I am in Git Bash when executing the command it still uses Windows paths. So then I tried following (surround with quotes):
$ "docker run --rm -v $PWD:/data composer --help"
bash: docker run --rm -v /c/Users/Marco:/data composer --help: No such file or directory
Now it is unable to find the directory.
I also tried without the $PWD variable, but this doesn't make a difference.
How do I make this work on Windows?
This should work:
$ docker run --rm -v //c/Users/Marco:/data composer --help
Try MSYS_NO_PATHCONV=1 docker run ...
Git Bash tries to convert the path for other Windows commands.

Resources