I have a Docker machine that I'm installing OpenCV 2.4.11
However, there is an error happening that I indeed found a solution, but it's temporary.
When I run my Python script that uses cv2
, throws this error message:
Error: libdc1394 error: Failed to initialize libdc1394
I saw that this is the only thread that fixed my problem, but temporarily: ctypes error: libdc1394 error: Failed to initialize libdc1394
I added the following line to my Dockerfile
, but that didn't affected my VM.
RUN ln /dev/null /dev/raw1394
However, if I enter that command while the VM is running (docker run -it ...
), it indeed makes things work! However, that doesn't solves my problem, because I need it to be ok on startup, and if I re-enter the VM, the problem comes back.
My Dockerfile:
# Pull base image.
FROM library/ubuntu
MAINTAINER Ivan Seidel <[email protected]>
RUN apt-get update
#
# Python
#
RUN apt-get install -y python python-dev python-pip python-virtualenv
#
# Node.js and NPM
#
RUN apt-get install -y nodejs nodejs-legacy npm git --no-install-recommends
#
# Install OpenCV
#
RUN apt-get install -y python-opencv --no-install-recommends
RUN ln /dev/null /dev/raw1394
#
# Clear cache
#
RUN rm -rf /var/lib/apt/lists/*
#
# Specific data
#
EXPOSE 80
COPY . /data
WORKDIR /data
RUN npm install --production
CMD ["bash"]
Good use cases for volumesVolumes are the preferred way to persist data in Docker containers and services. Some use cases for volumes include: Sharing data among multiple running containers. If you don't explicitly create it, a volume is created the first time it is mounted into a container.
Dockerfile Command to Keep the Container Running Method 1: You can use the -t (pseudo-tty) docker parameter to keep the container running. Method 2: You can run the container directly passing the tail command via arguments as shown below. Method 3: Another method is to execute a sleep command to infinity.
Docker supports a keyboard combination to gracefully detach from a container. Press Ctrl-P, followed by Ctrl-Q, to detach from your connection.
Okay. I spent a entire day on it.
Basically, the link between /dev/raw1394
and /dev/null
is not permanent. You can bash into your VM, call ln /dev/null /dev/raw1394
, but it will last only until you re-start your container.
What I had to do, that seemed to be the simplest, but not the perfect approach, is to place the linking during the startup of the Container.
I thought in Running it as a service, but seemed too much for a simple job.
The way I finally came to work, (it's not pretty, but works), is by changing the CMD
of the Dockerfile:
CMD sh -c 'ln -s /dev/null /dev/raw1394'; <your-script-here>
I got the same issue, when I changed the python command from python2 to python3. My line in the Dockerfile:
RUN ln -sf /usr/bin/python3 /usr/bin/python
Everytime starting a freshly build image as a container, I had to manually change the link.
I tried to use the command as execform of RUN in the Dockerfile and this solved my problem:
RUN ["ln", "-sf", "/usr/bin/python3", "/usr/bin/python"]
Now, python3 starts with the command python, without a manual setup of the link.
I encountered the same issue when I using an opencv python container.
I've tried to add "ln /dev/null /dev/raw1394" in many files in the ubuntu, in order to run it at the boot of container, but all failed.
Then I find the --device for docker run command.
So we can use like:
docker run --device /dev/null:/dev/raw1394 ...
It works on my container.
Actually, it is quite noising to input --device /dev/null:/dev/raw1394 every time when you run. But I cannot find a way to set device in Dockerfile.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With