Dockerfile 中的 SSHFS 挂载失败,除非它来自 ENTRYPOINT

问题描述

我正在尝试通过 SSHFS 从容器到远程服务器,并在 Dockerfile 构建期间创建挂载。

如果在已经运行的容器中执行,mount 命令会起作用,并且如果我将命令设为入口点也会起作用(但是我必须在最后用 ; 串接真正的入口点脚本,这感觉也是笨手笨脚的。)

如果我将命令放在带有 RUN 的 Dockerfile 中,它会失败并显示 fuse: device not found,try 'modprobe fuse' first 错误

这是文件...

install.sh

#!/bin/bash

USAGE="install.sh <dir_to_parse> <filetype_to_parse>"
if [ $# -lt 2 ]
  then
    echo "$USAGE"
    exit 1
fi

REMOTE_DIR=$1 FILE_EXTENSION=$2 docker-compose -p '' -f docker-compose.yml up -d --build 

docker-compose.yml

version: "3"
services:
  source.test:
    build:
      context: .
      dockerfile: ./Dockerfile
    image: test.source
    container_name: test.source
    environment:
      ELASTIC_HOST: “http://<redacted>:<redacted>”
      REMOTE_SERVER: <redacted>
      REMOTE_USER: <redacted>
      REMOTE_KEY: /etc/ssl/certs/<redacted>
      FeedER_URL: http://<redacted>/api
      MONGOHOST: mongo
      WALKDirs: <redacted>
      REMOTE_DIR: ${REMOTE_DIR}
      FILE_EXTENSION: ${FILE_EXTENSION}      
    volumes:
      - /etc/ssl/certs/:/etc/ssl/certs/
    ports:
      - 127.0.0.1:6000:80
    cap_add:
      - SYS_ADMIN
    devices:
      - "/dev/fuse:/dev/fuse"
    security_opt:
      - "apparmor:unconfined"
networks:
  default:
    external:
      name: test

Dockerfile

FROM ubuntu:18.04

RUN apt-get update && apt-get -y install \
    fuse \
    sshfs
        
copY <redacted> /etc/ssl/certs/<redacted>
copY fuse.conf /etc/fuse.conf
RUN chown root:root /etc/fuse.conf
RUN chmod 644 /etc/fuse.conf

RUN mkdir /mnt/filestobeparsed

# Fails with fuse: device not found 
RUN sshfs username@<xxx.xxx.xxx.xxx>:/remote/path /mnt/filestobeparsed -o StrictHostKeyChecking=no,IdentityFile=/etc/ssl/certs/<redacted>,auto_cache,reconnect,transform_symlinks,follow_symlinks,allow_other
ENTRYPOINT tail -f /dev/null

# Works but is klugy
#ENTRYPOINT sshfs username@<xxx.xxx.xxx.xxx>:/remote/path /mnt/filestobeparsed -o StrictHostKeyChecking=no,allow_other;  tail -f /dev/null

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...