在 Ubuntu Server 16.04 上启动 docker-ce (18.06.1-ce, build e68fc7a) 后,创建如下:
$ ifconfig
docker0 Link encap:Ethernet HWaddr 02:42:fe:36:81:72
inet addr:172.17.0.1 Bcast:0.0.0.0 Mask:255.255.0.0
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
不幸的是,我的电脑在这个网络上。这意味着一旦 docker 启动,我就会失去与服务器的 ssh 连接。
尝试 1
几个论坛都说要添加以下内容/etc/docker/daemon.json
:
{
"bip": "192.168.1.1/24"
}
尝试 2,使用这个 SO 接受的答案
一种可行的解决方案正在运行:
sudo ip addr add dev docker0 192.168.1.1/24
sudo ip addr del dev docker0 172.17.0.1/16
资料来源:forums.docker.com
虽然这是一个可能的解决方案,但我必须在 docker 服务启动后才这样做。我不能做的事情,因为我同时失去了连接。
尝试 3,遵循@Light.G 的回答
添加-bip
toExecStart
行后,尝试启动 docker 给出(journalctl -xe):
-- Unit docker.socket has begun starting up.
Sep 11 11:13:19 PTLISLABHLC01 systemd[1]: Listening on Docker Socket for the API.
-- Subject: Unit docker.socket has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.socket has finished starting up.
--
-- The start-up result is done.
Sep 11 11:13:19 PTLISLABHLC01 systemd[1]: docker.service: Start request repeated too quickly.
Sep 11 11:13:19 PTLISLABHLC01 systemd[1]: Failed to start Docker Application Container Engine.
-- Subject: Unit docker.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit docker.service has failed.
--
-- The result is failed.
Sep 11 11:13:19 PTLISLABHLC01 systemd[1]: docker.socket: Unit entered failed state.
Sep 11 11:13:19 PTLISLABHLC01 polkitd(authority=local)[1062]: Unregistered Authentication Agent for unix-process:15666:32644036 (system bus name :1.56, object path /org/freedesktop/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8) (disconnected from bus)
这里唯一的错误是你应该使用--bip
而不是-bip
. 检查接受的答案!