Ubuntu18重启docker服务失败问题备忘

环境信息

  1. 操作系统:Ubuntu 18.04.2
  2. Docker:18.06.1-ce

现象

执行命令service restart docker,提示启动失败:

root@hedy:~# systemctl restart docker
Failed to restart docker.service: Unit docker.service not found.

原因

  1. 依稀记得这台机器上的Docker是用snap安装的,执行snap命令查看服务,果然看到了docker:
root@hedy:~# snap services
Service         Startup  Current  Notes
docker.dockerd  enabled  active   -
  1. 执行命令docker.help可以看到更多snap的信息:
root@hedy:~# docker.help
Docker snap: Docker Linux container runtime.

Due to the confinement issues on snappy, it requires some manual setup to make docker-snap works on your machine.
We'll take you through the steps needed to set up docker snap work for you on ubuntu core and ubuntu classic.

On Ubuntu classic, before installing the docker snap,
please run the following command to add the login user into docker group.
    sudo addgroup --system docker
    sudo adduser $USER docker
    newgrp docker

On Ubuntu Core 16, after installing the docker snap from store,
you need to connect the home interface as it's not auto-connected by default.
    sudo snap connect docker:home :home

Then have fun with docker in snappy.

正确的重启方式

执行命令snap restart docker即可重启docker服务:

root@hedy:~# snap restart docker
Restarted.

欢迎关注我的公众号:程序员欣宸

在这里插入图片描述

你可能感兴趣的:(备忘录)