xianlubird / mydocker

<<自己动手写docker>> 源码
Apache License 2.0
1.98k stars 560 forks source link

executable file not found in $PATH" #14

Open timchenxiaoyu opened 7 years ago

timchenxiaoyu commented 7 years ago

uname -a Linux i-5x80cleb 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

sudo ./mydocker run -ti busybox sh {"level":"info","msg":"createTty true","time":"2017-08-24T14:34:11+08:00"} {"level":"error","msg":"Run command for creating mount point failed exit status 32","time":"2017-08-24T14:34:11+08:00"} {"level":"info","msg":"command all is sh","time":"2017-08-24T14:34:11+08:00"} {"level":"info","msg":"init come on","time":"2017-08-24T14:34:11+08:00"} {"level":"info","msg":"Current location is /root/mnt/4672873324","time":"2017-08-24T14:34:11+08:00"} {"level":"error","msg":"Exec loop path error exec: \"sh\": executable file not found in $PATH","time":"2017-08-24T14:34:11+08:00"} exec: "sh": executable file not found in $PATH {"level":"error","msg":"Unmount /root/mnt/4672873324 error exit status 1","time":"2017-08-24T14:34:11+08:00"}

BSWANG commented 7 years ago

Pls check following command output: dpkg -l | grep linux-image-extra If the command output is empty, Pls install the packages by command apt-get update; apt-get install linux-image-extra-$(uname -r) linux-image-extra-virtual.

timchenxiaoyu commented 7 years ago

dpkg -l | grep linux-image-extra ii linux-image-extra-3.13.0-128-generic 3.13.0-128.177 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP ii linux-image-extra-3.13.0-24-generic 3.13.0-24.47 amd64 Linux kernel extra modules for version 3.13.0 on 64 bit x86 SMP ii linux-image-extra-virtual 3.13.0.128.137 amd64 Transitional package.

timchenxiaoyu commented 7 years ago

why close my unsolved question ???

timchenxiaoyu commented 7 years ago

my os is ubuntu14.04 and core is 3.13.x

BSWANG commented 7 years ago

我们没能复现这个问题,可以通过修改代码看一下这个报错的时候的报错内容以及执行的操作参数吗? {"level":"error","msg":"Run command for creating mount point failed exit status 32","time":"2017-08-24T14:34:11+08:00"}

timchenxiaoyu commented 7 years ago

run again err change

./mydocker run -ti busybox sh {"level":"info","msg":"createTty true","time":"2017-09-08T10:46:53+08:00"} {"level":"info","msg":"command all is sh","time":"2017-09-08T10:46:53+08:00"} {"level":"info","msg":"init come on","time":"2017-09-08T10:46:53+08:00"} {"level":"info","msg":"Current location is /root/mnt/0691229025","time":"2017-09-08T10:46:53+08:00"} {"level":"error","msg":"Exec loop path error exec: \"sh\": executable file not found in $PATH","time":"2017-09-08T10:46:53+08:00"} exec: "sh": executable file not found in $PATH

NewbMiao commented 6 years ago

Have this problem too. i run mydocker in a privileged ubuntu14.04.4 docker on my mac.( dockfile: ubuntu14.04.4 )

root@b4d211aaaaa7:/tmp# mount -t aufs -o dirs=/root/writeLayer:/root/busybox  none /root/mnt
mount: wrong fs type, bad option, bad superblock on none,
       missing codepage or helper program, or other error
       (for several filesystems (e.g. nfs, cifs) you might
       need a /sbin/mount.<type> helper program)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so

root@b4d211aaaaa7:/tmp#  dmesg | tail
IPVS: ftp: loaded support on port[0] = 21
aufs test_add:264:mount[8869]: already stacked, /root/writeLayer (overlay)
IPVS: Creating netns size=2104 id=19
IPVS: ftp: loaded support on port[0] = 21
aufs test_add:264:mount[9312]: already stacked, /root/writeLayer (overlay)
IPVS: Creating netns size=2104 id=20
IPVS: ftp: loaded support on port[0] = 21
aufs test_add:264:mount[9363]: already stacked, /root/writeLayer (overlay)
aufs test_add:264:mount[9367]: already stacked, /root/writeLayer (overlay)
aufs test_add:264:mount[26270]: already stacked, /root/writeLayer (overlay)

I also install aufs-tools and mount It seems aufs is supported

root@b4d211aaaaa7:/tmp# grep aufs /proc/filesystems
nodev   aufs

How to make it work?

NewbMiao commented 6 years ago

Use vagrant is ok. I guess, for now overlay2 is default Storage Driver on docker(Version 17.09.0-ce-mac35 (19611)) when use it build images, it make container use overlay2 too. (Then i also tried build image after change Storage Driver to aufs, failed too )

Just use vagrant to avoid mount error

vagrant init ubuntu/trusty64
vagrant up
pibigstar commented 4 years ago

you can set /bin to PATH

export PATH=$PATH:/bin
ahululu commented 4 years ago

I got the same problem. and I don't kown why when I modify the file vim container/init.go and function RunContainerInitProcess,and log.Errorf("Exec loop path error %v", err) to log.Errorf("Exec xxloop path error %v", err),It just worked.

HhTtLllL commented 3 years ago

你好,我的环境是在docker 下运行ubuntu:14.04

docker 版本 Client: Version: 18.09.6 API version: 1.39 Go version: go1.10.8 Git commit: 481bc77 Built: Sat May 4 02:36:00 2019 OS/Arch: linux/amd64 Experimental: false

Server: Docker Engine - Community Engine: Version: 18.09.6 API version: 1.39 (minimum version 1.12) Go version: go1.10.8 Git commit: 481bc77 Built: Sat May 4 01:59:36 2019 OS/Arch: linux/amd64 Experimental: false

./mydocker run -ti busybox sh

error
{"level":"info","msg":"createTty true","time":"2020-12-09T06:23:54Z"} {"level":"error","msg":"Run command for creating mount point failed exit status 32","time":"2020-12-09T06:23:54Z"} {"level":"info","msg":"command all is sh","time":"2020-12-09T06:23:54Z"} {"level":"info","msg":"init come on","time":"2020-12-09T06:23:54Z"} {"level":"info","msg":"Current location is /root/mnt/5922811210","time":"2020-12-09T06:23:54Z"} {"level":"error","msg":"Exec loop path error exec: \"sh\": executable file not found in $PATH","time":"2020-12-09T06:23:54Z"} exec: "sh": executable file not found in $PATH {"level":"error","msg":"Unmount /root/mnt/5922811210 error exit status 1","time":"2020-12-09T06:23:54Z"}

想问问有没有解决的办法

VenkH commented 3 months ago

我的环境:VMware运行Centos 7虚拟机

我的报错:

[root@cMaster mini-docker]# mini-docker run -ti sh
{"level":"info","msg":"command all is sh","time":"2024-08-05T15:12:08+08:00"}
{"level":"info","msg":"init container","time":"2024-08-05T15:12:08+08:00"}
{"level":"info","msg":"command ","time":"2024-08-05T15:12:08+08:00"}
{"level":"info","msg":"command [sh]","time":"2024-08-05T15:12:08+08:00"}
{"level":"info","msg":"Current location is /home/joe/busybox","time":"2024-08-05T15:12:08+08:00"}
{"level":"error","msg":"Exec look path error exec: \"sh\": executable file not found in $PATH","time":"2024-08-05T15:12:08+08:00"}
{"level":"fatal","msg":"exec: \"sh\": executable file not found in $PATH","time":"2024-08-05T15:12:08+08:00"}

其他现象: 使用[root@cMaster mini-docker]# mini-docker run -ti /bin/sh 可以进入容器 但是无法使用ps、ls等命令

原因:没有设置环境变量export PATH=$PATH:/bin

解决方法: 在init_process.go文件中的RunContainerInitProcess函数中,修改环境变量,PATH添加/bin目录,具体代码如下:

.....   
if err := setUpMount(); err != nil {
log.Errorf("setup mount error %v", err)
}

// 修改环境变量,添加/bin目录
env_path := os.Getenv("PATH")
new_path := env_path + ":/bin"
os.Setenv("PATH", new_path)

path, err := exec.LookPath(cmdArray[0])
....