在 Ubuntu Server 16.04 中禁用 LXD 的默认安装

dhc*_*hen 5 lxd 16.04

自 Ubuntu 16.04 LXD 已成为 ubuntu-server 元包中的依赖项。因此升级和新安装都将安装 LXD。

这是一种非常烦人的行为。无论如何要禁用此行为?并非每台生产机器都需要启动容器服务。

小智 8

lxd 被推荐 ubuntu-server

root@c7:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:    16.04
Codename:   xenial

root@c7:~# apt-cache depends ubuntu-server|grep lxd
  Recommends: lxd

root@c7:~# apt-cache depends ubuntu-server|grep Recommends
  Recommends: lxd
  Recommends: snapd
Run Code Online (Sandbox Code Playgroud)

您可以使用

apt install --no-install-recommends ubuntu-server
Run Code Online (Sandbox Code Playgroud)

避免安装lxdsnapd

apt remove --purge lxd snapd
Run Code Online (Sandbox Code Playgroud)

在不删除 ubuntu-server 的情况下删除这些

root@c7:~# apt remove --purge lxd snapd
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  lxd* snapd*
0 upgraded, 0 newly installed, 2 to remove and 0 not upgraded.
After this operation, 37.4 MB disk space will be freed.
Do you want to continue? [Y/n] 
(Reading database ... 25405 files and directories currently installed.)
Removing lxd (2.0.0-0ubuntu4) ...
Warning: Stopping lxd.service, but it can still be activated by:
  lxd.socket
Purging configuration files for lxd (2.0.0-0ubuntu4) ...
Failed to stop lxd.service: Unit lxd.service not loaded.
dpkg: warning: while removing lxd, directory '/var/lib/lxd' not empty so not removed
Removing snapd (2.0.3) ...
Purging configuration files for snapd (2.0.3) ...
Processing triggers for man-db (2.7.5-1) ...
Run Code Online (Sandbox Code Playgroud)


小智 5

我认为您只是想禁用相关服务,而不是卸载它们。由于它们只是另一个服务,我们可以使用 systemctl 禁用它们

sudo systemctl disable lxd
sudo systemctl disable snapd
Run Code Online (Sandbox Code Playgroud)

如果有一天你想开始他们。

sudo systemctl start lxd
sudo systemctl start snapd
Run Code Online (Sandbox Code Playgroud)

就这么简单。