Error when running a container using --name flag - docker

when trying to run docker with a container name, I get the following error (on macOS)
~$ docker run -it myifort --name cont
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "--name": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled
Without the --name flag everything works as expected.

Try docker run -it --name cont myifort

Related

Docker works but deamon is not responding

Could you help me with this interesting case:
my docker creates images and runs containers fine
BUT
when I'm trying to run tests from testcontainers with command
docker run -it --rm -v $PWD:$PWD -w $PWD -v /var/run/docker.sock:/var/run/docker.sock my-image:1.0 mvn test
I receive
Error response from daemon: failed to create shim task: OCI runtime
create failed: runc create failed: unable to start container process:
exec: "mvn": executable file not found in $PATH: unknown.

docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545

When I tried to execute below command with Readonly it throws app an error(2nd code snip). When it's ran without the :ro container is starting without any issues. Please take a moment to look into this. Thanks
docker run -d -p 3000:80 --rm --name feedrun -v feedback:/app/feedback -v "/Users/balasubramanian/Learnings/docker/data-volumes-05-temporary-anonymous-volume:/app:ro" -v /app/node_modules -v /app/temp feedappi
Error:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: process_linux.go:545: container init caused: rootfs_linux.go:76: mounting "/var/lib/docker/volumes/39fb60b05636650476f670987768b5b34f9e4c7189cd04033659889377c5613b/_data" to rootfs at "/app/node_modules" caused: mkdir /var/lib/docker/overlay2/5ff4115be7c353f6427b24543471b9ff1562d76c279b2e3c464f4593441b888b/merged/app/node_modules: read-only file system: unknown
Working command without readonly instruction.
docker run -d -p 3000:80 --rm --name feedrun -v feedback:/app/feedback -v "/Users/balasubramanian/Learnings/docker/data-volumes-05-temporary-anonymous-volume:/app" -v /app/node_modules -v /app/temp feedappi

`$PATH: unknown` error when mounting the current directory in Docker

I want to use Docker to manage multiple Python versions (I recently got a Mac with Apple Silicon and I use old Python environment).
Since I need to read Python scripts on Docker and save the output files (for later use outside the Docker environment), I tried to mount a folder (on my Mac) following this post.
However, it shows this error:
$ docker run --name dpython -it python-docker -v $(pwd):/tmp /bin/bash
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "-v": executable file not found in $PATH: unknown.
ERRO[0000] error waiting for container: context canceled
It works without -v $(pwd):/tmp. I tried to specify different folders such as ~/ and /Users/ but they didn't work.
You must specify the volume before the image name:
$ docker run --name dpython -it -v $(pwd):/tmp python-docker /bin/bash

Launching A Docker Image

Getting an error message while trying to launch a Docker Image using the below command:
sudo docker run blackarchlinux/blackarch --security-opt seccomp=unconfined
docker: Error response from daemon: OCI runtime create failed: container_linux.go:380: starting container process caused: exec: "--security-opt": executable file not found in $PATH: unknown
ERRO[0001] error waiting for container: context canceled
Docker options need to go before the image name, so it should be
sudo docker run --security-opt seccomp=unconfined blackarchlinux/blackarch

Docker --mount throws: executable file not found in $PATH"

Running:
docker run 6740371b6542 --mount
docker run 6740371b6542 --mount source=aws,target=/root/.aws/,readonly
both produce the same error:
container_linux.go:265: starting container process caused "exec: \"--mount\": executable file not found in $PATH"
docker: Error response from daemon: oci runtime error: container_linux.go:265: starting container process caused "exec: \"--mount\": executable file not found in $PATH".
Can someone explain how to mount a file/folder from the host into the docker container? It seems --mount is the current/latest recommended way to do it.
switching the order of the parameters should resolve that problem
docker run --mount source=aws,target=/root/.aws/,readonly 6740371b6542
docker run executes a command as its last parameter. the error you received was due to the container not knowing what the --mount command is
In the future if you want to run a command in a container dont forget to use bash if you want to preserve path variables
docker run --mount source=aws,target=/root/.aws/,readonly 6740371b6542 /bin/bash -c mysql

Resources