[英]Ensure docker daemon is running on the host in script file
A Mac OSX runs a bash script where the docker command is used and often gives the error: Mac OSX运行bash脚本,其中使用docker命令并经常出错:
Cannot connect to the Docker daemon.
无法连接到Docker守护程序。 Is the docker daemon running on this host?
docker守护程序是否在此主机上运行?
Then I do Cmd+Space to open the Spotlight Search and type docker terminal in order to fire up the docker terminal so that the shell script does not fail 然后我做Cmd + Space打开Spotlight搜索并键入docker终端以启动docker终端,以便shell脚本不会失败
Is there a way to do this in the script so that it runs the docker daemon every time it runs? 有没有办法在脚本中执行此操作,以便每次运行时都运行docker守护程序?
I tried the following for no avail. 我尝试了以下无效。
docker-machine start default
I am running Docker version 1.12.0, build 8eab29e 我正在运行Docker版本1.12.0,构建8eab29e
You can put this command in your script: 您可以将此命令放在脚本中:
[[ $(docker-machine status) == "Stopped" ]] && docker-machine start
eval $(docker-machine env)
This will start docker-machine
if it is sopped and populate your current environment with docker machine related variables. 这将启动
docker-machine
如果它被淘汰并使用与docker机器相关的变量填充当前环境。
If docker-machine
is already running then this script will just set environment. 如果
docker-machine
已经运行,那么这个脚本将只设置环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.