Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
docker:在bash脚本中找不到命令,但可以在bash中使用docker_Bash_Git_Docker_Mingw W64 - Fatal编程技术网

docker:在bash脚本中找不到命令,但可以在bash中使用docker

docker:在bash脚本中找不到命令,但可以在bash中使用docker,bash,git,docker,mingw-w64,Bash,Git,Docker,Mingw W64,我正在windows server 2019上使用bash,并尝试运行一个简单的bash脚本,但当它达到这一行时: # check if containers are running, and stop them if they are not for the current project all_up_ids=$(docker ps -q); 我收到“未找到docker docker命令”错误。奇怪的是,我可以在bash中运行docker和docker compose,没问题。我已经设置

我正在windows server 2019上使用bash,并尝试运行一个简单的bash脚本,但当它达到这一行时:

# check if containers are running, and stop them if they are not for the current project
all_up_ids=$(docker ps -q); 
我收到“未找到docker docker命令”错误。奇怪的是,我可以在bash中运行docker和docker compose,没问题。我已经设置了环境变量。我能够让docker命令在bash中工作的唯一方法是将其放在我的.bashrc文件中

export PATH="$HOME/bin:$HOME/.local/bin:$PATH"
export PATH="$PATH:/mnt/c/Program\ Files/Docker/Docker/resources/bin"
alias docker=docker.exe
alias docker-compose=docker-compose.exe
我的环境设置是否仍有问题?感谢您的帮助

码头工人信息:

Client: Docker Engine - Enterprise
 Version:           19.03.5
 API version:       1.40
 Go version:        go1.12.12
 Git commit:        2ee0c57608
 Built:             11/13/2019 08:00:16
 OS/Arch:           windows/amd64
 Experimental:      true

Server: Docker Engine - Enterprise
 Engine:
  Version:          19.03.5
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.12.12
  Git commit:       2ee0c57608
  Built:            11/13/2019 07:58:51
  OS/Arch:          windows/amd64
  Experimental:     true

~/.bashrc
脚本仅针对交互式终端执行,这意味着每次打开终端窗口时,
~/.bashrc
都会在该会话中执行。所以这里定义的任何东西都不能用于脚本,因为它们是在非交互模式下执行的


我宁愿将您的配置放入
~/.bash\u profile
。当您打开登录shell时,该脚本只执行一次,因此,当您登录并启动脚本时,该脚本也将可用。

请参见哦,我如何使该脚本可用?还是我只是走错路了?完成bash的noob。我正在使用git bash,所以当你说登录时,我还需要做些什么吗?不,在这种情况下,你打开的每个新git bash终端都是一个登录shell,所以
~/.bash\u配置文件
总是在shell启动过程中执行。所以我将它添加到我的~/.bash\u配置文件中并重新启动shell,我仍然收到错误,我甚至在脚本中尝试了一个更简单的语句:docker版本号luck@AustinJones您是否通过bash执行脚本?