Learn how to set up autostart for unprivileged LXC containers. Our LXC/LXD Support team is here to help you with your questions and concerns.
How to Set Up Autostart for Unprivileged LXC Containers
Did you know that unprivileged containers in LXC have lower privileges?
In other words, they run as a regular user and not as a root user.
Furthermore, autostarting these containers comes in handy if we want to make sure specific services or applications in the containers are available once the host system starts.
Let’s take a quick look at how to configure autostart for unprivileged LXC containers:
- To begin with, log into the Proxmox VE web interface.
- Then, head to the “Local” node.
- Now, click “LXC” and we will be able to see a list of our containers.
- Next, we have to choose the unprivileged container for which we want to set up autostart.
- At this point, head to the Options tab in the container details view.
- Then, locate the “Autostart” or “Start at boot” option and set it to “Yes” or “Enable.”
- Finally, save the changes.
Alternatively, we can accomplish the same goal via the command line as seen here:
- Run the following command to enable autostart for an unprivileged LXC container:
pct set ID_or_Name_of_Unprivileged_Container --onboot yes
This command will change the container configuration by setting the “onboot” option to “yes”.
- Then, apply the changes with this command:
pct applyconfig ID_or_Name_of_Unprivileged_Container
How to use systemd user mode to Autostart Unprivileged LXC Containers
- First, create the file ~/.config/systemd/user/lxc-autostart.service in the home of the user with the LXC containers:
[Unit] Description="Lxc-autostart for lxc user" [Service] Type=oneshot ExecStart=/usr/bin/lxc-autostart ExecStop=/usr/bin/lxc-autostart -s RemainAfterExit=1 [Install] WantedBy=default.target
- Now, run this as the user:
systemctl --user enable lxc-autostart
Here, the –user option informs systemctl that we are using in user mode.
- Then, run the following command:
sudo loginctl enable-linger $user
Here, $user is the name of the user that has the LXC containers.
Our experts would like to point out that systemd has to start a systemd user instance for $user at boot. Otherwise, it will start only at the moment $user logs in.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
In brief, our Support Experts demonstrated how to set up autostart for unprivileged LXC containers.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments