Startup/ Init Script / Bootstrap provisioning on lxc


New Member
May 15, 2017
Hi All,
I feel like I'm missing something blatantly obvious, but I can't seem to find it.
I would like to automate the process of creating a Centos LXC, boostrapping it, then running the provisioning.

The hang up is the Centos 7 LXC doesn't have openssh-server installed by default.
Which I believe should be fine.

So, is there a startup script that I can write that gets run when the container is started?

I wasn't able to find that, so I looked into pct exec.
While I can run:
pct exec 106 'hostname'

I cannot seem to run:
pct exec 106 'yum install -y openssh-server'

When I try I get the following error:
root@pve:/etc/pve/nodes/pve/lxc# pct exec 106 "yum install -y openssh-server"
lxc-attach: attach.c: lxc_attach_run_command: 1290 No such file or directory - failed to exec 'yum install -y openssh-server'

I AM able to run (without the quotes):
pct exec 106 yum install openssh-server

But I can't add the -y switch without the tool complaining:
root@pve:/etc/pve/nodes/pve/lxc# pct exec 106 yum install -y openssh-server
Unknown option: y
400 unable to parse option
pct exec <vmid> [<extra-args>]

Am I just barking up the wrong tree here? Is there a simpler way of prepping a container for provisioning by ansible,chef,puppet, etc..?

Basically I figure if I can get ssh listening on the lxc then I can do whatever I want for provisioning, but I need to figure out how to script the installation of openssh-server on the new container.

Also is there a better way to view the pct documentation other than the man pages? I would even take an online version of the man pages so I could scan through and search through it.

Thank you!


New Member
May 15, 2017
Hi Dietmar,

that worked great! Thanks so much.

Is the "--" documented some place? I feel like I'm missing some basic documentation somewhere.

Thanks again!


Proxmox Staff Member
Staff member
Aug 29, 2006
> man pct


The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!