12

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 <ivanseidel@gmail.com>

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"]
Community
  • 1
  • 1
Ivan Seidel
  • 2,394
  • 5
  • 32
  • 49

4 Answers4

7

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>

Ivan Seidel
  • 2,394
  • 5
  • 32
  • 49
3

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.

  • This did not work for me. I changed to `RUN ["ln", "-s", "/dev/null", "/dev/raw1394"]` in the Dockerfile, rebuilt the image, but no link exists on start of the container. – erroric Jul 10 '18 at 17:48
1

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.

Colin Ji
  • 803
  • 7
  • 15
0

I added the link creation to the command: of the docker-compose.yml file I had for the app service. It looked something like

version: '3'
services:
  thumbor:
    build: .
    ports:
      - 8888:8888
    command: bash -c "ln /dev/null dev/raw1394 && thumbor"

The ln command only runs on a docker-compose up and not on a docker-compose run --rm app bash.

I got the bash -c from this answer.

erroric
  • 991
  • 1
  • 11
  • 22