LeanMan
LeanMan

Reputation: 534

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

Its not clear from the documentation what is the difference between lxc start and lxc-start and the --help provides different usages and switches. Tutorials use both variants but delving into the documentation a bit deeper, it seems that lxc-start is suited for applications running inside the container whereas lxc start is for starting a container. Either way its not clear since it doesn't explain if the commands are links of one another or completely different. I am erring on the side of "they are different as in different binaries, different code paths, but eventually converge under the hood with a few modifications".

Documentation: 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.

Documentation: 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

Upvotes: 5

Views: 1758

Answers (3)

AnrDaemon
AnrDaemon

Reputation: 367

In very crude terms, 'LXC' is a container platform itself, managed by 'lxc-*' tools and provide very basic set of functions.

Contrary, 'LXD' is an orchestration tool built upon LXC.

Again, this is a very crude analogy and does not cover nuances and specifics.

If all you need is a small set of persistent isolated containers (Cloud instance, gaming server), an ability to finely tune behavior of each long-running instance, LXC is likely all you would ever need.

If you want to create and destroy containers daily by the hundred, using templates and automation tools, look into LXD.

Upvotes: 2

user597630
user597630

Reputation: 571

  1. Both LXC and LXD are implementations of Linux Containers.
  2. LXC and LXD are related, both developed by the same team at https://linuxcontainers.org/
  3. LXC predates LXD.
  4. Both are based on the common liblxc library.
  5. LXC is written in C while LXD is written in the Go language.
  6. LXD comes with a hypervisor (container manager) that makes it more user-friendly for most users.

If you are a new user and try to decide which to use, go for LXD.

References: https://blog.simos.info/comparison-between-lxc-and-lxd/

Upvotes: 2

LeanMan
LeanMan

Reputation: 534

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

It states,

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.

Upvotes: 1

Related Questions