在docker容器中安装伪tty

在docker容器中安装伪tty,docker,tty,Docker,Tty,我的docker容器有一个脚本,可以在生产环境中打开到真实TTY设备的串行连接,类似于Arduino。对于没有实际连接设备的本地测试,我想创建一个模拟的TTY,然后运行指向这个伪TTY的相同docker容器。当我创建伪tty并运行docker run--device=/dev/pts/2 test时,我得到一个错误: docker:daemon的错误响应:oci运行时错误:container\u linux.go:247:starting container process caused“pro

我的docker容器有一个脚本,可以在生产环境中打开到真实TTY设备的串行连接,类似于Arduino。对于没有实际连接设备的本地测试,我想创建一个模拟的TTY,然后运行指向这个伪TTY的相同docker容器。当我创建伪tty并运行
docker run--device=/dev/pts/2 test
时,我得到一个错误:

docker:daemon的错误响应:oci运行时错误:container\u linux.go:247:starting container process caused“process\u linux.go:359:container init caused\”rootfs\u linux.go:65:creating device nodes response\\\\\\\\\\\“open/var/lib/docker/aufs/mnt/242A13EADB75E802BAB8DC01C701C4AD671195B93F7B956000F32AC091E24/dev/pts/2:permission\\\”\"".

如果使用
--privileged
运行并连接到正在运行的容器中,则路径不在
/dev/pts
中。我的主机是Debian jessie实例


有没有办法从容器内部连接到这个伪tty?还是有更好的方法来做这个测试呢?

使用
--privileged
,你可以只
--volume/dev/pts:/dev/pts
docker run-t
中的
-t
对你有用吗?很久以前@Matt,但你找到解决方案了吗?介意发布一个答案吗?@panepeter我们的堆栈使用上面@larsks的方法,没有
--privileged
,在docker compose的上下文中使用,hth!使用
--privileged
,您可能只需要
--volume/dev/pts:/dev/pts
docker run-t中的
-t
对您有用吗?很久以前@Matt,但您找到解决方案了吗?介意发布一个答案吗?@panepeter我们的堆栈使用上面@larsks的方法,没有
--privileged
,在docker compose的上下文中使用,hth!