/etc/ser2net.yml
在 docker 容器中编辑文件。
在 ser2net 文件中添加了以下条目:
connection: &con40000 accepter: tcp,40000 enable: on options: banner: *banner kickolduser: true telnet-brk-on-sync: true connector: serialdev, /dev/ttyUSB0, 115200n81,local nobreak
重新启动docker容器:
docker stop my_container docker start my_container
回到容器中
docker exec -it my_container bash
但重启失败
ser2net
:$ systemctl restart ser2net System has not been booted with systemd as init system (PID 1). Can't operate. Failed to connect to bus: Host is down
这是完整的ser2net.yml
文件
%YAML 1.1
---
# This is a ser2net configuration file, tailored to be rather
# simple.
#
# Find detailed documentation in ser2net.yaml(5)
# A fully featured configuration file is in
# /usr/share/doc/ser2net/examples/ser2net.yaml.gz
#
# If you find your configuration more useful than this very simple
# one, please submit it as a bugreport
define: &banner \r\nser2net port \p device \d [\B] (Debian GNU/Linux)\r\n\r\n
connection: &con0096
accepter: tcp,2000
enable: on
options:
banner: *banner
kickolduser: true
telnet-brk-on-sync: true
connector: serialdev,
/dev/ttyS0,
9600n81,local
connection: &con1096
accepter: tcp,2001
enable: on
options:
banner: *banner
kickolduser: true
telnet-brk-on-sync: true
connector: serialdev,
/dev/ttyS1,
9600n81,local
connection: &con0192
accepter: tcp,3000
enable: on
options:
banner: *banner
kickolduser: true
telnet-brk-on-sync: true
connector: serialdev,
/dev/ttyS0,
19200n81,local
connection: &con1192
accepter: tcp,3001
enable: on
options:
banner: *banner
kickolduser: true
telnet-brk-on-sync: true
connector: serialdev,
/dev/ttyS1,
19200n81,local
connection: &con40000
accepter: tcp,40000
enable: on
options:
banner: *banner
kickolduser: true
telnet-brk-on-sync: true
connector: serialdev,
/dev/ttyUSB0,
115200n81,local nobreak
答案1
好的,感谢 @realpclaudio 指出 - 它没有实现 systemd。
以下两种解决方案有效:
$ docker exec -it hacpy_container pkill ser2net
$ docker exec -it hacpy_container ser2net -c /path/to/ser2net.yml
Unable to start mdns: Out of memory #<- this still restarted ser2net
和
$ service ser2net restart
Unable to start mdns: Out of memory #<- this still restarted ser2net
最初,我对这个问题有点困惑无法启动 mdns:内存不足但它并没有导致ser2net
端口映射出现任何问题。