【问题标题】:Command sudo: not found [closed]命令 sudo:未找到 [关闭]
【发布时间】:2019-04-10 14:52:22
【问题描述】:

在执行我的 init.sh 时,我正在调用命令:

sudo bash ${INSTALLPATH}seafile.sh start

接下来,错误:

seafile_1_f2341d904d27 | /bin/sh: 1: sudo: not found

发生。

打开目录“bin”并查看“sh”只是一些不可读的字符..

调用 init.sh 的 dockerfile 通过:

 FROM debian
#FROM armv7/armhf-debian

MAINTAINER me

# install packages
RUN apt-get update && apt-get install sudo -y

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
ca-certificates \
python2.7 \
python-setuptools \
python-imaging \
python-ldap \
python-urllib3 \
sqlite3 \
wget

# Copy scripts
ADD ./scripts /scripts

# set environment variables
ENV SERVER_NAME mdh-seafile
ENV SERVER_IP 127.0.0.1
ENV FILESERVER_PORT 8082
ENV SEAFILE_DIR /data
ENV SEAFILE_VERSION seafile-server-6.3.4
ENV INSTALLPATH /opt/seafile/${SEAFILE_VERSION}/

# clean for smaller image
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Volumes for persistent configuration
VOLUME /opt/seafile/

# added
COPY /opt/seafile/${SEAFILE_VERSION}/seafile.sh .
COPY /opt/seafile/${SEAFILE_VERSION}/seahub.sh .


# set entrypoint
ENTRYPOINT sudo bash /scripts/init.sh

初始化.sh:

else
  # start seafile
  # whoami -> Output: root
  sudo bash ${INSTALLPATH}seafile.sh start
  sudo bash ${INSTALLPATH}seahub.sh start
  # keep seafile running in foreground to prevent docker container shutting down
  while true; do
    sudo tail -f /opt/seafile/logs/seafile.log
    sleep 10
  done

fi

我通过调用 sudo bash install.sh 来执行所有操作,它正在执行链接到组件的 docker-compose 文件。

Docker-Compose:

version: '2'
services:

  db:
    #image: hypriot/rpi-mysql
    image: mysql
    environment:
      - MYSQL_ROOT_PASSWORD=###
    volumes:
    - /mnt/data/mysql:/var/lib/mysql

  duply:
    build: .
    volumes:
      - ./config:/config
      - /mnt/data:/mnt/data
      - ./webinterface:/var/www/html/MyDigitalHome
      - /mnt/guestbackup:/mnt/guestbackup/backup
      #- /mnt/usb-removable:/usb-removable
    ports:
      - "8080:80"
      - "24:22"
    links:
      - db
  seafile:
    build: seafile/
    volumes:
      - ./seafile/config:/config
      - /mnt/data/seafile:/data
    ports:
      - "8000:8000"
      - "8082:8082"
    environment:
      - SEAFILE_ADMIN=###@mydigitalhome.xy
      - SEAFILE_ADMIN_PW=###


  owncloud:
    build: owncloud/
    volumes:
      - /mnt/data/owncloud:/data
      - ./owncloud/config:/var/www/html/config
    ports:
      - "8090:80"
    links:
      - db:mysql

目前的错误是:

ERROR: Service 'seafile' failed to build: COPY failed: stat /var/lib/docker/tmp/docker-builder845725722/opt/seafile/seafile-server-6.3.4/seafile.sh: no such file or directory

Attaching to mdh_seafile_1_f2341d904d27, mdh_db_1_46bebe733124, mdh_duply_1_170a5db26129, mdh_owncloud_1_260c3a56f2a5
seafile_1_f2341d904d27 | bash: seafile.sh: No such file or directory
seafile_1_f2341d904d27 | bash: seahub.sh: No such file or directory
seafile_1_f2341d904d27 | tail: cannot open '/opt/seafile/logs/seafile.log' for reading: No such file or directory
seafile_1_f2341d904d27 | tail: no files remaining

【问题讨论】:

  • 请分享更多关于您的问题的信息。你是根吗? sudo 可能不存在,因为您是 root。甚至可能没有 bash。 sh 文件是二进制文件,这是正常的。
  • @samthegolden 没有 sudo 我得到错误:找不到文件。
  • 你能分享你的 Dockerfile 的第一行吗?从线。这样我们就可以知道您使用的是 Ubuntu、Alpine 还是其他发行版?
  • 你已经是容器的root,不需要sudo。
  • @BMitch - 没有 sudo 我得到错误:没有这样的目录。

标签: shell docker debian


【解决方案1】:

我假设您在 docker 中运行它。 您可以添加到您的 dockerfile 中

RUN apt update && apt install -y sudo

这应该可以解决您的问题。

【讨论】:

  • 我已经这样做了。 Sudo 在其他任何地方都可以正常工作。
【解决方案2】:

debian 镜像开始,您需要安装sudo,您可以通过将RUN apt-get update && apt-get install sudo -y 添加到Dockerfile 的开头来完成。然后使用docker build . 重建您的映像并再次运行该命令。

【讨论】:

  • 评论不适用于扩展讨论或调试会话;这个对话是moved to chat。请务必edit回复以反映讨论结果。
猜你喜欢
  • 2017-08-09
  • 2015-07-23
  • 2018-03-18
  • 2017-04-25
  • 1970-01-01
  • 2014-04-07
  • 1970-01-01
  • 2018-03-19
  • 2014-07-06
相关资源
最近更新 更多