Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
FREEDOM251

Freedom251 › Blog › containers

Getting Started With LXC Containers on an Ubuntu VPS (LXD 5.21 and Ubuntu 24.04)

By Freedom251 Team · · 9 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

On Ubuntu, the practical way to run LXC system containers is to install LXD, Canonical’s manager, and use its lxc command-line client. Install the LXD Snap, grant a trusted operator access, initialize the daemon, then launch an Ubuntu 24.04 container with one command.

This guide follows Canonical’s LXD 5.21 workflow and explains the choices that matter on a VPS: container versus virtual machine, local versus remote administration, networking, storage, updates and the security consequences of LXD access.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What “LXC containers” means on Ubuntu

LXC is the underlying Linux container technology: processes run with isolated filesystems, process trees, users and network namespaces while sharing the VPS kernel. LXD is the management daemon and API that creates, starts, stops, snapshots and monitors those containers. The lxc command is the client used to control LXD.

Therefore, an Ubuntu VPS tutorial normally tells you to install LXD rather than assemble low-level LXC configuration by hand. LXD can also manage virtual machines, but the default command in this guide creates a container.

Check the VPS before installing

Use a supported Ubuntu Server installation and leave room for the image, container filesystem and your application data. Canonical’s first-steps exercise specifies at least 20 GiB of free disk space. That is a tutorial prerequisite, not a universal sizing rule or a performance guarantee: databases, logs and multiple instances may require considerably more.

  • Operating system: Ubuntu Server on the VPS. Ubuntu cloud images may already contain LXD; check what is installed before adding another copy.
  • Disk: Reserve at least 20 GiB free for the introductory workflow, then budget separately for each workload and its backups.
  • Privileges: You need administrative access to install the Snap and change group membership.
  • Virtualization: Hardware virtualization is required for LXD virtual machines, not for ordinary containers. A VPS without that capability can still run containers.
  • Network policy: Decide which application ports should be public and which management addresses, if any, should reach the LXD daemon.

Container or virtual machine?

The image alias can look identical while the instance type differs. A container shares the host kernel and generally has lower overhead; a VM supplies a separate guest kernel and stronger isolation at the cost of virtualization requirements and additional resources.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Choice Command Host requirement Use when
Ubuntu container lxc launch ubuntu:24.04 name Standard Linux container support You want a lightweight Ubuntu system sharing the VPS kernel.
Ubuntu virtual machine lxc launch ubuntu:24.04 name --vm Working CPU virtualization support You need a separate guest kernel or VM-level isolation.

If the VPS provider does not expose virtualization extensions, stay with containers and omit VM-specific steps.

Install LXD with the recommended Snap

Canonical’s installation guidance recommends the LXD Snap when it is available. The guide was updated June 24, 2026 and identifies the default stable LTS track as the usual choice. Snap packages update automatically by default; organizations that need change control can hold or schedule updates using their normal Snap administration policy.

  1. Connect to the VPS over SSH or its provider console.
  2. Install LXD:
sudo snap install lxd

On an Ubuntu cloud image, LXD may already be present. Avoid creating a second, conflicting installation; use the existing manager if it is correctly installed and accessible.

Grant local access without giving it away

LXD’s local Unix socket is intentionally powerful. Canonical states: “Local access to LXD through the Unix socket always grants full access to LXD.” A user who can control the daemon may attach host files or devices and change security settings for every instance. Treat membership in the lxd group as equivalent to a root-trust decision.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Append the current account to the group:
sudo usermod -aG lxd "$USER"
  1. Start a shell with the new group membership:
newgrp lxd

Only add operators who are already trusted with root-level control of the VPS. Do not grant the group to an application account, a contractor who needs access to one container, or an untrusted web process.

Initialize the LXD daemon

LXD must be initialized before it can create instances. For a straightforward first setup, run:

lxd init --minimal

The minimal path creates the basic storage and networking configuration needed for a first container. It is appropriate for learning and a simple VPS. Use the interactive form instead when you must choose a particular storage backend, configure storage pools deliberately, select network behavior or apply other server-wide settings.

Initialization is a host-level operation. Decide where container data should live before filling the VPS, especially if the root disk is small or your provider offers a separate volume.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Launch your first Ubuntu container

The ubuntu: remote provides official Ubuntu images. This command downloads the Ubuntu 24.04 LTS image if necessary, creates an instance called first and starts it:

lxc launch ubuntu:24.04 first

To create an instance without starting it, use lxc init:

lxc init ubuntu:24.04 second

A stopped instance is useful when you want to set configuration before its first boot. Start it later with the usual instance start operation, then verify its state.

Confirm state and obtain the address

List instances immediately after launch:

lxc list

The list includes the instance name, running state, IP addresses, instance type and snapshot information. A healthy first result normally shows first as running with an address on the LXD-managed network.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

For more detail, inspect the instance:

lxc info first

lxc info reports details such as architecture, process ID and usage data. Use it when you need to distinguish a stopped instance from one that is running but has a guest problem.

Open a shell and install software

Once the instance is running, execute a command inside it without opening a separate SSH service:

lxc exec first -- bash

From that shell, manage packages and services as you would on an Ubuntu system. Keep the container’s packages and image-derived software updated after launch. Exit the shell to return to the VPS.

Understand container networking and IP addresses

LXD normally creates a private bridge and gives containers addresses through its network configuration. The address displayed by lxc list is the starting point for internal communication and administration. It does not automatically make an application publicly reachable from the Internet.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Treat two networking jobs separately:

  • Container application traffic: Publish only the service ports an application actually needs. Decide whether traffic should terminate at the container, a host reverse proxy or an external load balancer.
  • LXD administration: The daemon is local Unix-socket-only by default. Remote clients and the web UI require an explicitly configured HTTPS listener.

Use the VPS provider’s firewall as well as the Ubuntu host firewall when those controls are available. Document which public address, proxy or load balancer terminates each service, and avoid opening every container port merely because a bridge address exists.

When a container has no address

  • Confirm the instance is actually running with lxc list.
  • Use lxc info name to check for deeper state and startup problems.
  • Check whether the LXD initialization created the expected network and whether the VPS provider permits the required virtual networking.
  • Inspect the guest’s network service from lxc exec name -- bash; an application can be healthy even when its network service has not completed startup.
  • If you changed host firewall rules, verify that DHCP and established container traffic were not blocked.

Remote administration: keep the LXD API private by default

LXD’s local-only default is the safest starting point. If a remote client or web UI is genuinely required, configure an HTTPS address deliberately through the core.https_address setting. Canonical’s tutorial demonstrates binding the UI to [::1]:8443, which limits access to the local host.

For production remote administration:

  • Bind HTTPS to one intended address rather than every interface.
  • Allow the management port through firewalls only for authorized hosts or subnets.
  • Do not expose the daemon broadly to the public Internet.
  • Separate management access from application ports and record who is allowed to use each path.

An HTTPS listener is an administrative control plane, not a substitute for an application reverse proxy. Keep its firewall policy narrower than the policy for a public website or API.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Security baseline for production containers

Prefer unprivileged containers

Use LXD’s default unprivileged containers unless a documented workload requirement says otherwise. Privileged containers reduce isolation; Canonical’s security guidance warns that they are not root-safe. If software demands elevated capabilities, investigate whether a narrower device, profile or capability change solves the requirement before converting the whole instance.

Patch every layer

Apply Ubuntu security updates on the VPS and inside each container. Keep LXD itself current as well. The Snap’s automatic update behavior is convenient, but production operators should still know which version is installed and use an approved maintenance or change-control process when automatic changes need to be held or scheduled.

Protect the operator boundary

Review the members of the lxd group whenever staff, keys or automation change. Local socket access is full LXD access, not a narrowly scoped “container shell” permission. Remove stale accounts and avoid embedding a user’s broad LXD credentials in unattended application code.

Back up before risky work

Take snapshots or backups before major package upgrades, storage changes or application migrations, and test restoration separately. A snapshot on the same VPS is useful for quick rollback but is not protection against loss of the VPS disk or provider account; keep an independent backup when the data matters.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Useful operating patterns

Use clear instance names

Name instances for their role, such as web-01, db-01 or staging, rather than relying on generic names after the first experiment. Consistent names make firewall rules, backup inventories and incident notes easier to audit.

Keep images and workloads distinct

The official ubuntu:24.04 image is a starting filesystem, not an application release. Install only the packages the workload needs, record configuration changes and update the running system. Rebuilding a disposable service from documented configuration is often safer than accumulating undocumented manual changes.

Use stopped creation for planned configuration

When an instance needs deliberate storage, network or device settings, create it with lxc init, apply the approved configuration, then start it. Use lxc launch for a quick, standard instance whose defaults are acceptable.

Choosing the right setup approach

Decision Recommended starting point When to choose the alternative
Package source LXD Snap on Ubuntu Use another distribution package only when your organization has a specific compatibility or lifecycle requirement.
Initialization lxd init --minimal Use interactive lxd init for deliberate storage, networking or server-wide choices.
Administration Local Unix socket Enable HTTPS only for a real remote-client or UI need, then firewall it to authorized sources.
Instance type Unprivileged container Use a VM when a separate kernel is required and the VPS exposes virtualization; use a privileged container only for a justified, reviewed exception.

Troubleshooting the first launch

lxc cannot connect to LXD

Check that the daemon is installed and initialized, then verify that your current shell picked up the lxd group with newgrp lxd. If the account was just changed, opening a new login session also refreshes group membership.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The image does not download

Confirm the VPS has outbound Internet access, DNS resolution and enough free disk space. The ubuntu: remote must be reachable to retrieve the official image; a provider firewall or exhausted filesystem can interrupt the operation.

The instance starts and immediately stops

Run lxc info name and inspect the instance’s state and process information. Check the guest command or service launched as PID 1; a container stops when its initial process exits. Correct the guest configuration, then start the instance again.

A public service is unreachable

First test it from inside the container, then from the VPS, and only afterward from the Internet. Confirm the application is listening on the intended interface and port, the host and provider firewalls allow that port, and any proxy forwards to the container’s current address. Do not solve an application-port problem by exposing the LXD management API.

Version and lifecycle notes

The documented workflow targets LXD 5.21.8 and Ubuntu 24.04 LTS images. Canonical’s installation guide identifies the stable LTS Snap track as the normal choice, and Snap channels, image aliases and security recommendations can change. Before deploying a new VPS, verify the current Canonical documentation and the image version you intend to run, then record those versions in your infrastructure notes.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The Bottom Line

For a first Ubuntu VPS deployment, install the LXD Snap, grant lxd access only to root-trusted operators, run lxd init --minimal, and launch ubuntu:24.04 with lxc launch. Keep the instance unprivileged, patch every layer, publish only required application ports and leave the LXD API local unless tightly firewall-restricted remote administration is unavoidable.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

containersLinuxLXCLXDServer SecurityUbuntuVPS

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.