【发布时间】:2018-06-14 09:13:50
【问题描述】:
我正在使用this guide 使用 Amazon Lex 和 Raspberry Pi 构建语音工具包,但我需要使用 Docker。 问题是指南卷曲和运行的脚本需要访问 /dev/tty。我可以在 running docker 容器时授予对 /dev/tty 的访问权限,但在构建容器时我不知道该怎么做。
我的 Dockerfile 看起来像这样:
FROM resin/rpi-raspbian
WORKDIR /app
ADD . /app
#The script requires these
RUN apt-get update
RUN apt-get install iputils-ping
#The script has to be run with sudo priviliges but not as root
USER root
ADD /sudoers.txt /etc/sudoers
RUN chmod 440 /etc/sudoers
RUN useradd -ms /bin/bash lex
RUN echo 'lex:test' | chpasswd
RUN curl https://get.pimoroni.com/phatdac | bash
USER lex
EXPOSE 80
#Comment the last RUN command and uncomment this
#CMD curl https://get.pimoroni.com/phatdac | bash
当我尝试用
构建容器时docker build -t raspi1 .
它在脚本上崩溃,因为它无法访问 /dev/tty。
运行容器时,我可以使用此脚本授予对 /dev/tty 和 /dev/snd 的访问权限
#!/bin/sh
docker run -ti --rm \
-v /dev/snd:/dev/snd \
--privileged \
raspi7
然后尝试在启动时使用 Dockerfile 中的 CMD 脚本。但是如果我这样做了,那么我每次运行时都需要使用脚本,并且在脚本完成后我还需要在其他东西上运行,这在构建时在 Dockerfile 上会很好。
TLDR; 构建 docker 镜像时如何授予 /dev/tty 和 /dev/snd 权限?
【问题讨论】:
-
不相关,但你应该将你的 RUN 分组(见docs.docker.com/engine/userguide/eng-image/…),你的行
user ROOT是无用的,因为默认情况下你是root,除非你做USER xxx你以后做什么 -
谢谢,但那些还没有解决这个问题。
标签: linux amazon-web-services docker dockerfile amazon-lex