lxc 命令 lxc start 和 lxc-start 等有什么区别?

What is the difference between lxc commands lxc start and lxc-start, etc?

从文档中不清楚 lxc start 和 lxc-start 之间的区别是什么,--help 提供了不同的用法和开关。教程使用这两种变体,但更深入地研究文档,lxc-start 似乎适用于容器内的应用程序 运行,而 lxc start 用于启动容器。无论哪种方式都不清楚,因为它没有解释命令是彼此链接还是完全不同。我错误地认为“它们在不同的二进制文件、不同的代码路径中是不同的,但最终通过一些修改在引擎盖下收敛”。

文档:http://manpages.ubuntu.com/manpages/bionic/man1/lxc-start.1.html

$ lxc-start --help
Usage: lxc-start --name=NAME -- COMMAND

lxc-start start COMMAND in specified container NAME

Options :
  -n, --name=NAME        NAME of the container
  -d, --daemon           Daemonize the container (default)
  -F, --foreground       Start with the current tty attached to /dev/console
  -p, --pidfile=FILE     Create a file with the process id
  -f, --rcfile=FILE      Load configuration file FILE
  -c, --console=FILE     Use specified FILE for the container console
  -L, --console-log=FILE Log container console output to FILE
  -C, --close-all-fds    If any fds are inherited, close them
                         If not specified, exit with failure instead
                         Note: --daemon implies --close-all-fds
  -s, --define KEY=VAL   Assign VAL to configuration variable KEY
      --share-[net|ipc|uts]=NAME Share a namespace with another container or pid

Common options :
  -o, --logfile=FILE               Output log to FILE instead of stderr
  -l, --logpriority=LEVEL          Set log priority to LEVEL
  -q, --quiet                      Don't produce any output
  -P, --lxcpath=PATH               Use specified container path
  -?, --help                       Give this help list
      --usage                      Give a short usage message
      --version                    Print the version number

Mandatory or optional arguments to long options are also mandatory or optional
for any corresponding short options.

See the lxc-start man page for further information.

文档:http://manpages.ubuntu.com/manpages/bionic/man7/lxc.7.html

$ lxc start --help
Usage: lxc start [<remote>:]<container> [[<remote>:]<container>...]

Start containers.

Options:
    --debug  (= false)
        Enable debug mode
    --force-local  (= false)
        Force using the local unix socket
    --no-alias  (= false)
        Ignore aliases when determining what command to run
    --stateful  (= false)
        Store the container state (only for stop)
    --stateless  (= false)
        Ignore the container state (only for start)
    --verbose  (= false)
        Enable verbose mode

来自 https://discuss.linuxcontainers.org/t/comparing-lxd-vs-lxc/24,

上面写着,

lxd

lxd is the LXD daemon. For interacting with the daemon (to create and manage containers, for instance), you want to use the lxc command. You generally don’t want to invoke lxd directly – unless you need to run lxd init or something; check man lxd or lxd --help for more info on what you can do with running lxd directly, but once you get it running from your init system, you probably won’t need to invoke it directly again unless you are debugging LXD itself.

The lxc command is the LXD front-end (“LXD Client” is how I think of it).

However, if you’re trying to use LXD, you should avoid using any commands that start with lxc- (that’s lxc, followed by a short hyphen)! These commands are associated with LXC.

lxc

LXC commands start with lxc- (that’s lxc followed by a short hyphen). If there’s no hyphen, just the literal command lxc, that’s associated with LXD.

  1. LXC 和 LXD 都是 Linux 容器.
  2. 的实现
  3. LXC 和 LXD 是相关的,都是由 https://linuxcontainers.org/
  4. 的同一个团队开发的
  5. LXC 早于 LXD。
  6. 两者都基于共同的 liblxc 库。
  7. LXC是用C语言写的,LXD是用Go语言写的。
  8. LXD 带有一个 hypervisor(容器管理器),这使得它对大多数用户来说更加友好。

如果您是新用户并试图决定使用哪个,请选择 LXD。

参考文献:https://blog.simos.info/comparison-between-lxc-and-lxd/