bash 运行 docker 命令时出现语法错误

bash syntax error while running docker command

我在 运行 docker ps 命令时遇到错误,即 -

> An error occurred trying to connect: Get
> http://localhost:2375/v1.21/containers/json?all=1: dial tcp
> 127.0.0.1:2375: ConnectEx tcp: No connection could be made because the target machine actively refused it.

我试图使用本论坛中的说明更正错误 - https://forums.docker.com/t/windows-an-error-occurred-trying-to-connect/4384

我在最后一步遇到错误,即 运行 git bash -

中的此命令
FOR /f "tokens=*" %i IN ('"C:\Program Files\Docker Toolbox\docker-machine.exe" env --shell cmd machinename') DO %i

我得到的错误是

bash: syntax error near unexpected token `('

对解决这个问题有什么帮助吗?我试图转义单引号和双引号,但没有用。

I am facing an error in the last step i.e. running this command in git bash -

FOR /f "tokens=*" %i IN ('"C:\Program Files\Docker Toolbox\docker-machine.exe" env --shell cmd machinename') DO %i

这是 batch 语法,在 bash 中应该有效:

eval `docker-machine env`