I needed to manage my LXC container, and for some reason the noVNC wasn't working for it. It proved to be better than I hoped.

First, ssh into your host node (or, use the Shell option while logged into Proxmox on the desired node).

Now, in order to get a list of the containers, you need to execute: pct list - This list should look similar to:

VMID    STATUS    LOCK    NAME
400         running                      debian9-build-test-ca-srv01
401         running                      ubuntu1604-build-test-ca-srv01

Now, if you need to get a shell into them, you need to use the VMID instead of the hostname, unlike traditional LXC where you execute by name.

In order to connect, now run: pct exec $CONTAINER_ID /bin/bash

You will be presented with a terminal into the container, it's important to note you can sub out the /bin/bash for any command you choose - here is an alias you can use to connect quicker over terminal:

#!/bin/bash
set -e
CONTAINER=$1
pct exec $CONTAINER /bin/bash

This script will bubble up errors, get the container ID as the first parameter (ie: pcte 400), and run pct exec into /bin/bash of the container by it's ID.

You could enhance this script to make it execute by name if necessary, a quick draft would look like:

#!/bin/bash
set -e
CONTAINER=$1
out=`pct list | grep ${1} | grep "[0-9][0-9][0-9]`
if [ "${out}" != "" ]; then
  pct exec $out /bin/bash
else
  echo "Failed to find container ${1}, try again? Containers list is as follows:"
  pct list
fi

Till next time!

Mike

Senior Software Engineer, Labber, Sysadmin. I make things scale rapidly. Optimize everything.

Read More