This is ok to add device which by serial id:
docker run -it --rm --device /dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A101A9A7-if00-port0 -v /dev:/dev ubuntu /bin/bash
This is not ok to add device which by serial path:
docker run -it --rm --device /dev/serial/by-path/pci-0000:00:14.0-usb-0:8:1.0-port0 -v /dev:/dev ubuntu /bin/bash
It reports error:
invalid argument "/dev/serial/by-path/pci-0000:00:14.0-usb-0:8:1.0-port0" for "--device" flag: bad format for path: /dev/serial/by-path/pci-0000:00:14.0-usb-0:8:1.0-port0
See 'docker run --help'.
Same error if do escape string for : as next:
docker run -it --rm --device /dev/serial/by-path/pci-0000\:00\:14.0-usb-0\:8\:1.0-port0 -v /dev:/dev ubuntu /bin/bash
As I know, for bind mount, we now could use something like --mount type=bind,source=/colon:path/test,destination=/data to handle it, see this.
So my question is: for --device, what could I do?
Answer for myself, from this discussion:
It seems CLI not support escaping the colons, currently the only way is to make symbol link like next:
ln -s /dev/serial/by-path/pci-0000:00:14.0-usb-0:8:1.0-port0 /dev/serial/by-path/mydevice01
docker run -it --rm --device /dev/serial/by-path/mydevice01 -v /dev:/dev ubuntu /bin/bash
This is what I made workaround currently.
Related
I am trying to build an image and then run it in one command. Using stackoverflow question I have menaged to scrape this command:
docker run --rm -it -p 8000:8000 -v "%cd%":/docs $(docker build -q .)
However it produces an error:
docker: invalid reference format.
See 'docker run --help'.
First part of the command ( docker run --rm -it -p 8000:8000 -v "%cd%":/docs .) works properly on already built image the problem lies inside $(docker build -q .). Dockerfile is inside the folder I have opened in cmd.
You need to run it in PowerShell, not cmd.
Try docker run --rm -it -p 8000:8000 -v ${PWD}:/docs $(docker build -q .).
docker run -it -v C:\Users\HP\Documents\Deep Learning\potato_project:/potato_project -p 8605:8605 --entrypoint /bin/bash tensorflow/serving
It is showing docker:invalid reference format.
enter image description here
Try your path into quotes:
docker run -it -v "C:\Users\HP\Documents\Deep Learning\potato_project:/potato_project" -p 8605:8605 --entrypoint /bin/bash tensorflow/serving
Its seems its due to the space in the path name
I am following a tutorial series on yt https://www.youtube.com/watch?v=FkrpUaGThTQ
how to make an os soo
when in **Build for x86 ** use the command make build-x86_64 then it shows this error `
make: *** No rule to make target 'build-x86_64'. Stop.
`
I dont know how to fix it
Per the original YouTube author of the tutorial, this is the fix :
Try one of the following commands when entering the docker container from your host OS
For Linux, MacOS, WSL, etc :
docker run --rm -it -v "$pwd":/root/env myos-buildenv
docker run --rm -it -v "$PWD":/root/env myos-buildenv
docker run --rm -it -v "$(pwd)":/root/env myos-buildenv
Windows Powershell :
docker run --rm -it -v "${pwd}:/root/env" myos-buildenv
Windows CMD :
docker run --rm -it -v "%cd%":/root/env myos-buildenv
You just need to go back one directory by typing
"cd .."
then enter another command
"cd env" to move into the env folder
then you can enter "make build x86_64" command
Make the "MakeFile" file name as "makefile" and run the command "make build-x86_64"
Same problem I had. Just go on with Carey S.Turner`s answer.
Windows Powershell: docker run --rm -it -v "${pwd}:/root/env" myos-buildenv
Windows CMD: docker run --rm -it -v "%cd%":/root/env myos-buildenv
I had error with cmd but powershell worked fine for me.
I had the same error I found that it could be fixed by doing this bit right
Enter build environment:
Linux or MacOS: docker run --rm -it -v "$(pwd)":/root/env myos-buildenv
Windows (CMD): docker run --rm -it -v "%cd%":/root/env myos-buildenv
Windows (PowerShell): docker run --rm -it -v
"${pwd}:/root/env" myos-buildenv
Please use the linux command if you are using WSL, msys2 or git bash NOTE: If you are having trouble with an unshared drive, ensure your docker daemon has access to the drive you're development environment is in. For Docker Desktop, this is in "Settings > Shared Drives" or "Settings > Resources > File Sharing".
(https://github.com/davidcallanan/os-series/blob/ep1/README.md)
My error came out of me not doing the "$(pwd)" bit correctly
I have created a docker image for opencv and facial reckognition to simplify the setup process.
But the recognize.py script needs X Server to show the image result. Here is what I have done so far:
sudo docker run -t -d --name opencv opencv:latest
sudo docker exec -it opencv bash /extract-embeddings.sh
sudo docker exec -it opencv bash /train-model.sh
All is fine so far. The last step is the actual comparison that displays the result in an image.
sudo docker exec -it opencv bash /face-recognition.sh
It gives the output:
[INFO] loading face detector...
[INFO] loading face recognizer...
No protocol specified
: cannot connect to X server :0
I have tried running the container with the following command:
sudo docker run -t -d --name opencv -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix opencv:latest
But it doesn't help.
Try running this,
xhost +
sudo docker run --rm -ti --net=host --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix --env="QT_X11_NO_MITSHM=1" <image_name> <arguments>
Other might face issue regarding the image not getting rendered on screen or getting a blank screen with no image, for them add --env="_X11_NO_MITSHM=1" to the above script while running the docker image. It will solve the problem.
For further information, I would recommend you guys check out the below references.
Reference 1
Reference 2
It looks like the xauth is the issue for viewing of the image.
The details are at Can you run GUI applications in a Docker container?
It may happen that also the XAuthority is needed.
First, make sure that the host's $XAUTHORITY is defined.
And second, add the following parameters to the docker run command:
-v $XAUTHORITY:/tmp/.XAuthority -e XAUTHORITY=/tmp/.XAuthority
An example of a complete command:
sudo docker run --rm -ti --net=host --ipc=host -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $XAUTHORITY:/tmp/.XAuthority -e XAUTHORITY=/tmp/.XAuthority --env="QT_X11_NO_MITSHM=1" <image_name> <arguments>
I'm trying to enter interactive mode using an official Microsoft .Net Core image and use typical .Net commands such as 'dotnet build', but all I get is an '>' cursor. What am I doing wrong?
I'm using the following command:
docker run -it -v $(pwd):/app' -w '/app' -p 8000:80 mcr.microsoft.com/dotnet/core/sdk /bin/bash
I was hoping to get a root command prompt, but all I'm getting is '>'
Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
Run a command in a running container
Options:
-d, --detach Detached mode: run command in the background
--detach-keys string Override the key sequence for detaching a
container
-e, --env list Set environment variables
-i, --interactive Keep STDIN open even if not attached
--privileged Give extended privileges to the command
-t, --tty Allocate a pseudo-TTY
-u, --user string Username or UID (format:
<name|uid>[:<group|gid>])
-w, --workdir string Working directory inside the container
After running your container, run command docker ps to take [Container ID]
And after you are able to run the command like there docker exec -it [Container ID] bash .
You are misssing the initial quote here:
-v $(pwd):/app'
That should be:
-v "$(pwd):/app"
It needs to be a double-quote for $(pwd) to be evaluated correctly by the shell. Otherwise the shell will send the literal $(pwd) which is not a valid path.
It seems no one gives a direct answer, this one works for me:
docker run --rm -it -v $PWD:/app -w /app -p 8000:80 mcr.microsoft.com/dotnet/core/sdk /bin/bash