2

尝试从 Docker 容器访问 uEye 以太网摄像头,我成功地可以通过网络从主机访问它,但容器没有运气。

我正在使用 docker-compose 并将特权设置为 true 如下

version: '3'

services:

  #Engineering UI Service
  web:
    build:
     context: .
     dockerfile: Dockerfile
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    expose:
      - 8000
    networks:
      - backend
    container_name: web
    privileged: true
    cap_add:
      - SYS_ADMIN
    restart: always
    tty: true
networks:
  backend:
      driver: bridge

Dockerfile 已设置

FROM centos:7
# set environment varibles
USER root
ENV PYTHONUNBUFFERED 1

RUN yum -y update && yum -y install wget

# INSTALL CAMERA
RUN echo "Installing uEye camera" \
     && mkdir /uEye && cd /uEye \
     && wget http://test.com/uEye-Linux-4.90.06-64.tgz \
     && tar xvf uEye-Linux-4.90.06-64.tgz -C /uEye \
     && sh "ueyesdk-setup-4.90.06-eth-amd64.gz.run"

在容器内运行“/usr/local/share/ueye/bin/ueyesetid”时我收到“没有连接摄像头!”

4

1 回答 1

0

我可以解决这个问题的唯一方法是设置 cap-add=ALL 和 -v /dev:/dev。不建议这样做,因为它允许容器拥有所有主机权限,但这是我可以让它通过以太网与相机对话的唯一方法。

于 2020-09-10T06:09:24.490 回答