Macos 如何在mac上脱机运行docker

Macos 如何在mac上脱机运行docker,macos,docker,Macos,Docker,当我安装在mac上时,它从我的内联网获取了一个ip。 之后,当我切换到另一个网络时,它向我显示了错误 $ bash --login '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh' Starting "default"... (default) Waiting for an IP... Too many retries waiting for SSH to be av

当我安装在mac上时,它从我的内联网获取了一个ip。 之后,当我切换到另一个网络时,它向我显示了错误

$ bash --login '/Applications/Docker/Docker Quickstart Terminal.app/Contents/Resources/Scripts/start.sh'
Starting "default"...
(default) Waiting for an IP...
Too many retries waiting for SSH to be available.  Last error: Maximum number of retries (60) exceeded
Regenerate TLS machine certs?  Warning: this is irreversible. (y/n): Regenerating TLS certificates
Detecting the provisioner...
Error getting SSH command: Something went wrong running an SSH command!
command : cat /etc/os-release
err     : exit status 255
output  :
Error checking TLS connection: Something went wrong running an SSH command!
command : ip addr show dev eth1
err     : exit status 255
output  :


                        ##         .
                  ## ## ##        ==
               ## ## ## ## ##    ===
           /"""""""""""""""""\___/ ===
      ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
           \______ o           __/
             \    \         __/
              \____\_______/


Error getting IP address: Something went wrong running an SSH command!
command : ip addr show dev eth1
err     : exit status 255
output  :
docker is configured to use the default machine with IP
For help getting started, check out the docs at https://docs.docker.com
我知道与“默认”中配置的网关相关的东西 我跑

脱机并重新启动docker机器 默认值已生成。之后,我上网并尝试下载一张图片。 但我遇到了连接错误

$ docker run -t -i --name myFirstContainer ubuntu:14.04 /bin/bash
Unable to find image 'ubuntu:14.04' locally
Pulling repository docker.io/library/ubuntu
Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/ubuntu/images. You may want to check your internet connection or if you are behind a proxy.
我想这是因为当我离线时,没有接口被分配给“默认”

$ docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "df562e1cae477be7d2dc09a30ee21b0871a2202731506d3f6db3df9c1abb4cad",
        "Scope": "local",
        "Driver": "bridge",
        "IPAM": {
            "Driver": "default",
            "Config": [
                {
                    "Subnet": "172.17.0.0/16"
                }
            ]
        },
        "Containers": {},
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        }
    }
]
$ docker-machine create --driver virtualbox default
Running pre-create checks...
(default) Default Boot2Docker ISO is out-of-date, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v1.10.0
(default) Downloading /Users/tt/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v1.10.0/boot2docker.iso...
(default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(default) Copying /Users/tt/.docker/machine/cache/boot2docker.iso to /Users/tt/.docker/machine/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

This machine has been allocated an IP address, but Docker Machine could not
reach it successfully.

SSH for the machine should still work, but connecting to exposed ports, such as
the Docker daemon port (usually <ip>:2376), may not work properly.

You may need to add the route manually, or use another related workaround.

This could be due to a VPN, proxy, or host file configuration issue.

You also might want to clear any VirtualBox host only interfaces you are not using.
Checking connection to Docker...
Docker is up and running!
To see how to connect Docker to this machine, run: docker-machine env default

$ docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "307267097a1845e6ac7b2a6a67bf800b8cda05f036c649a92af59a44689a55ab",
        "Scope": "local",
        "Driver": "bridge",
        "IPAM": {
            "Driver": "default",
            "Config": [
                {
                    "Subnet": "172.17.0.0/16"
                }
            ]
        },
        "Containers": {},
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        }
    }
]

$ docker run -t -i --name myFirstContainer ubuntu:14.04 /bin/bash
Unable to find image 'ubuntu:14.04' locally
14.04: Pulling from library/ubuntu
8387d9ff0016: Pull complete
3b52deaaf0ed: Pull complete
4bd501fad6de: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:0844055d30c0cad5ac58097597a94640b0102f47d6fa972c94b7c129d87a44b7
Status: Downloaded newer image for ubuntu:14.04
重新连接到网络并重建“默认”时的状态

$ docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "df562e1cae477be7d2dc09a30ee21b0871a2202731506d3f6db3df9c1abb4cad",
        "Scope": "local",
        "Driver": "bridge",
        "IPAM": {
            "Driver": "default",
            "Config": [
                {
                    "Subnet": "172.17.0.0/16"
                }
            ]
        },
        "Containers": {},
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        }
    }
]
$ docker-machine create --driver virtualbox default
Running pre-create checks...
(default) Default Boot2Docker ISO is out-of-date, downloading the latest release...
(default) Latest release for github.com/boot2docker/boot2docker is v1.10.0
(default) Downloading /Users/tt/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v1.10.0/boot2docker.iso...
(default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
Creating machine...
(default) Copying /Users/tt/.docker/machine/cache/boot2docker.iso to /Users/tt/.docker/machine/machines/default/boot2docker.iso...
(default) Creating VirtualBox VM...
(default) Creating SSH key...
(default) Starting the VM...
(default) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...

This machine has been allocated an IP address, but Docker Machine could not
reach it successfully.

SSH for the machine should still work, but connecting to exposed ports, such as
the Docker daemon port (usually <ip>:2376), may not work properly.

You may need to add the route manually, or use another related workaround.

This could be due to a VPN, proxy, or host file configuration issue.

You also might want to clear any VirtualBox host only interfaces you are not using.
Checking connection to Docker...
Docker is up and running!
To see how to connect Docker to this machine, run: docker-machine env default

$ docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "307267097a1845e6ac7b2a6a67bf800b8cda05f036c649a92af59a44689a55ab",
        "Scope": "local",
        "Driver": "bridge",
        "IPAM": {
            "Driver": "default",
            "Config": [
                {
                    "Subnet": "172.17.0.0/16"
                }
            ]
        },
        "Containers": {},
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        }
    }
]

$ docker run -t -i --name myFirstContainer ubuntu:14.04 /bin/bash
Unable to find image 'ubuntu:14.04' locally
14.04: Pulling from library/ubuntu
8387d9ff0016: Pull complete
3b52deaaf0ed: Pull complete
4bd501fad6de: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:0844055d30c0cad5ac58097597a94640b0102f47d6fa972c94b7c129d87a44b7
Status: Downloaded newer image for ubuntu:14.04
$docker machine create--驱动程序virtualbox默认值
正在运行预创建检查。。。
(默认)默认Boot2Docker ISO已过期,正在下载最新版本。。。
(默认)github.com/boot2docker/boot2docker的最新版本是v1.10.0
(默认)从下载/Users/tt/.docker/machine/cache/boot2docker.isohttps://github.com/boot2docker/boot2docker/releases/download/v1.10.0/boot2docker.iso...
(默认)0%…10%…20%…30%…40%…50%…60%…70%…80%…90%…100%
正在创建计算机。。。
(默认)将/Users/tt/.docker/machine/cache/boot2docker.iso复制到/Users/tt/.docker/machine/machines/default/boot2docker.iso。。。
(默认)正在创建VirtualBox虚拟机。。。
(默认)正在创建SSH密钥。。。
(默认)正在启动VM。。。
(默认)正在等待IP。。。
正在等待机器运行,这可能需要几分钟。。。
计算机正在运行,正在等待SSH可用。。。
正在检测已创建实例的操作系统。。。
正在检测供应器。。。
使用boot2docker进行设置。。。
正在将证书复制到本地计算机目录。。。
正在将证书复制到远程计算机。。。
正在远程守护程序上设置Docker配置。。。
此计算机已分配IP地址,但Docker计算机无法
成功地到达它。
机器的SSH应该仍然可以工作,但是连接到暴露的端口,例如
Docker守护程序端口(通常为2376)可能无法正常工作。
您可能需要手动添加管线,或使用其他相关的解决方法。
这可能是由于VPN、代理或主机文件配置问题造成的。
您可能还希望清除任何未使用的VirtualBox纯主机接口。
正在检查与Docker的连接。。。
Docker正在运行!
要查看如何将Docker连接到此计算机,请运行:Docker machine env default
$docker网络检查网桥
[
{
“名称”:“桥梁”,
“Id”:“307267097a1845e6ac7b2a6a67bf800b8cda05f036c649a92af59a44689a55ab”,
“范围”:“本地”,
“司机”:“驾驶台”,
“IPAM”:{
“驱动程序”:“默认值”,
“配置”:[
{
“子网”:“172.17.0.0/16”
}
]
},
“容器”:{},
“选择”:{
“com.docker.network.bridge.default_bridge”:“true”,
“com.docker.network.bridge.enable_icc”:“true”,
“com.docker.network.bridge.enable_ip_伪装”:“true”,
“com.docker.network.bridge.host\u binding\u ipv4”:“0.0.0.0”,
“com.docker.network.bridge.name”:“docker0”,
“com.docker.network.driver.mtu”:“1500”
}
}
]
$docker run-t-i——名称myFirstContainer ubuntu:14.04/bin/bash
在本地找不到图像“ubuntu:14.04”
14.04:从库/ubuntu中提取
8387d9ff0016:拉动完成
3B52EAAF0ED:拉动完成
4bd501fad6de:拉动完成
a3ed95caeb02:拉动完成
摘要:sha256:0844055D30CAD5AC58097597A94640B0102F47D6FA972C94B7C129D87A44B7
状态:为ubuntu下载了更新的图像:14.04

即使在切换网络或离线时,我是否仍可以无缝运行docker?

根据我个人的经验,在docker在网络之间运行和关闭时移动mac电脑没有问题,因此我希望它正常工作。使用或类似解决方案时除外。这可能是一个潜在的问题吗?不,这只是交换网络。我的大学网络是B级专用网络,我的家庭网络是C级专用网络