Error on zsh: docker: Error response from daemon: invalid volume specification - bash

I have a bash script that composes a docker run command chaining different volumes with -v:
VOL_ONE="-v $PWD/path/one:/home/docker/app/path/one"
VOL_TWO="-v $PWD/path/two:/home/docker/app/path/two"
RUN_VOLUMES="$VOL_ONE $VOL_TWO"
docker run --rm -it $RUN_VOLUMES docker.myserver.io/path/to/image:latest command
It runs absolutely fine when I use bash to run it.
However when I run the exact same script using zsh instead of bash I get:
docker: Error response from daemon: invalid volume specification
I've tried both on Ubuntu and macOS, getting the exact same problem.

Does this work:
VOL_ONE=(-v $PWD/path/one:/home/docker/app/path/one)
VOL_TWO=(-v $PWD/path/two:/home/docker/app/path/two)
RUN_VOLUMES=(${VOL_ONE[*]} ${VOL_TWO[*]})
echo docker run --rm -it ${RUN_VOLUMES[*]} docker.myserver.io/path/to/image:latest command
If it prints the desired result, remove the echo.

Related

How to run a bash script from a Dockerfile on a Mac

I'm trying to run a bash script from a Docker Image on a Mac. Here is my Dockerfile
FROM bash
ADD app.sh /
ENTRYPOINT ["/bin/bash", "/app.sh"]
Error
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown.
This is a simple exercise in creating Docker Images where I need to execute app.sh when I run docker run.
Any idea what I'm doing wrong?
According to your error message, the file /bin/bash does not exist in your Docker image. Why is this?
The bash image puts the bash executable at /usr/local/bin/bash. Here's how I determined this:
$ docker run -it bash
bash-5.1# which bash
/usr/local/bin/bash
bash-5.1#
I ran the bash image with -it to make it interactive, then used the which command to give me the full path to bash, which is /usr/local/bin/bash.
For that reason, you need to change your Dockerfile like this:
FROM bash
ADD app.sh /
ENTRYPOINT ["/usr/local/bin/bash", "/app.sh"]

Docker keeps complaining about the input device is not TTY

I'm using Windows-10 and using GitBash entering in the command
$ docker run -ti ubuntu:latest bash
And it gives me this error message
"the input device is not a TTY. If you are using mintty, try prefixing the command with 'winpty'"
And so I placed in this command to switch to winpty
$ winpty docker.exe run -it --rm ubuntu:14.04 /bin/bash
And it still doesn't work. I know my ports are running correctly, and I installed ubuntu correctly.
At windows 10 and git bash this works for me:
winpty docker exec -it "CONTAINTER ID" sh

GitLab ci cannot start bash in container

Good day!
I am using powershell shell executor for gitlab runner. For the test I need to run bash in my php-fpm container but I get a strange error
docker exec -it phpfpm bash
error:
the input device is not a TTY. If you are using mintty, try prefixing the command with winpty
also i tried to run command with winpty prefix
winpty docker exec -it phpfpm bash
or
winpty -Xallow-non-tty docker exec -it phpfpm bash
but "winpty" is not internal or external
command, executable program, or batch file.
i installed git with standard windown shell option instead of MTY
also i tried to install winpty but it didn't work. Are there any options to solve this problem or what could be the problem?

Command Not Found with Dockerfile CMD

I have a Dockerfile that uses
CMD ['/usr/local/bin/gunicorn', '-b 0.0.0.0:8000', 'myapp.wsgi']
But when I run the container using docker run --rm myimage:latest I get an error:
/bin/sh: 1: [/usr/local/bin/gunicorn,: not found
Yet, when I run docker run --rm -it myimage:latest /bin/bash to go into the container, I can see that gunicorn runs, and running which gunicorn returns the correct path for gunicorn. Why is it failing to run?
Similarly, I planned on adding
ENTRYPOINT ['/entrypoint.sh']
to my Dockerfile, but when I run that, I get the error
/bin/sh: 1: /bin/sh: [/entrypoint.sh]: not found
The entrypoint.sh file contains:
#! /bin/bash
echo 'Starting app...'
cd /app || exit;
python manage.py migrate;
So why does it keep saying command not found when all the commands are there?
The issue here is the quotes. Use double " quotes.
From Docker Documentation:
The exec form is parsed as a JSON array, which means that you must use
double-quotes (“) around words not single-quotes (‘).
This is applicable for other instructions such as RUN, LABEL, ENV, ENTRYPOINT and VOLUME.

Docker - run error on window git bash for -v

I run docker in my win10, but use -v params has a error.
docker run --privileged=true -d --name=ubuntu14.04 -v e:/docker/data:/data ubuntu /bin/bash
error:
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: oci runtime error: container_linux.go:262: starting container process caused "exec: \"C:/Program Files/Git/usr/bin/bash\": stat C:/Program Files/Git/usr/bin/bash: no such file or directory".
When I ls this path just like error path pic:
If possible, try the same command in a regular DOS session, instead of a git bash.
That will avoid the git bash session to automatically resolve /bin/bash to C:/Program Files/Git/usr/bin/bash, which won't be known at all by the ubuntu container.
The OP confirms this is working, provided the following options are added:
--attach=STDIN
--privileged=true
winpty docker run -i -t test1 ./bin/sh
Will work on Windows OS.
Add two slashes before bin/sh to turn off GitBash's automatic path conversion.
docker run --privileged=true -d --name=ubuntu14.04 -v e:/docker/data:/data ubuntu //bin/bash
or if you're trying to attach to a running container
docker attach -it ubuntu //bin/bash

Resources