How to run a script in a container?

janvv

Active Member
Jun 21, 2020
63
10
28
66
52.24154182722349, 5.117853866801705
How can I run a shell script in a container after creation?
I can copy a script file into the container by using 'pct push <vmid> etc..'
But then...
How can I run it without login in?

I want to create a container fully automated and run some scripts in it to do intial configuration. This is the last step that I am missng.
 
From what I understand <command> can have no options or arguments to it. Gets very complex if you want some.
 
From what I understand <command> can have no options or arguments to it. Gets very complex if you want some.
Use pct exec <ct id> -- <command> <option1> <arg1> <option2> <arg2> ,,,
For example pct exec 100 echo -n arg1 arg2 will give an error (because of the -n and works fine without it) but pct exec 100 -- echo -n arg1 arg2 works as expected.
 
  • Like
Reactions: mathx and LnxBil

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, 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 yours easily in our online shop.

Buy now!