使用以下docker-compose.yml:
services:
scanner:
image: debian:buster
build:
context: ./scanner
environment:
- SOME=env
volumes:
- /srv/scanning:/srv/documents
devices:
- "/dev/bus/usb/001/002:/dev/bus/usb/001/002"
ports:
- "8022:22"
和以下Dockerfile:
FROM debian:buster
RUN apt update && DEBIAN_FRONTEND=noninteractive apt install -y \
openssh-server \
sane \
sane-utils \
wget \
&& rm -rf /var/lib/apt/lists/* \
&& wget http://www.brother.com/pub/bsc/linux/dlf/brscan4-0.4.2-1.amd64.deb && dpkg -i brscan4-0.4.2-1.amd64.deb
#RUN mkdir /var/run/sshd
ADD set_user_env.sh /set_user_env.sh
ADD run.sh /run.sh
ADD public_key.pub /public_key.pub
RUN chmod +x /*.sh
RUN mkdir -p /var/run/sshd && sed -i "s/UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config \
&& sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config \
&& touch /root/.Xauthority
EXPOSE 22
CMD ["/run.sh"]
构建和运行容器可以完美地工作,但是如果我通过SSH登录后运行命令 scanimage (或 scanadf ),则会得到一个核心文件。
使用gdb调试(直接从容器中)可得到以下输出: root @ 4bd921cbe331:〜#gdb scanimage核心
[... license details ...]
Reading symbols from scanimage...(no debugging symbols found)...done.
[New LWP 2028]
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error
Warning: couldn't activate thread debugging using libthread_db: Cannot find new threads: generic error
warning: Unable to find libthread_db matching inferior's thread library, thread debugging will not be available.
Core was generated by `scanimage'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007efd4ac4185b in __pthread_initialize_minimal_internal
294 nptl-init.c: No such file or directory.
有趣的是(或者不是?),我可以执行 sane-find-scanner 二进制文件而不会出现问题,它会正确列出扫描器。
更多调试:
root@425bf5deb998:~# ldd `which scanimage`
linux-vdso.so.1 (0x00007ffd57d8a000)
libsane.so.1 => /lib/x86_64-linux-gnu/libsane.so.1 (0x00007f1e04496000)
libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f1e04a93000)
libjpeg.so.62 => /lib/x86_64-linux-gnu/libjpeg.so.62 (0x00007f1e0422d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1e03e73000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1e03c6f000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1e03a51000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1e036be000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1e048ab000)
root@425bf5deb998:~# find / -name libpthread\* 2> /dev/null
/usr/lib/x86_64-linux-gnu/libpthread-2.27.so
/usr/lib/x86_64-linux-gnu/libpthread.so.0
root@425bf5deb998:~# l /usr/lib/x86_64-linux-gnu/libpthread-2.27.so
-rwxr-xr-x 1 root root 135K Mar 29 19:47 /usr/lib/x86_64-linux-gnu/libpthread-2.27.so
root@425bf5deb998:~# l /usr/lib/x86_64-linux-gnu/libpthread.so.0
lrwxrwxrwx 1 root root 18 Mar 29 19:47 /usr/lib/x86_64-linux-gnu/libpthread.so.0 -> libpthread-2.27.so