2.7. Running Commands in Virtual Machines and Containers¶
Virtuozzo Hybrid Server allows you to execute arbitrary commands inside virtual machines and containers by running them on the physical server, i.e. without the need to log in to the respective virtual machine or container. For example, this can be useful in these cases:
If you do not know the virtual machine or container login information, but need to run some diagnosis commands to verify that it is operational.
If the virtual machine or container has no network access.
In both cases, you can use the
prlctl exec command to run a command inside the respective virtual machine or container. By default, running
prlctl exec <command> is equivalent to executing
bash -c <command> in a Linux VM or container or
cmd /c <command> in a Windows VM. Add the
--without-shell option to run commands directly without the shell.
The session below illustrates the situation when you run the stopped SSH daemon inside a Linux virtual machine with the name of
# prlctl exec My_Linux /etc/init.d/sshd status openssh-daemon is stopped # prlctl exec My_Linux /etc/init.d/sshd start Starting sshd: [ OK ] # prlctl exec My_Linux /etc/init.d/sshd status openssh-daemon (pid 26187) is running...
Note the following:
You can use the
prlctl execcommand only inside virtual machines that have Virtuozzo guest tools installed.
prlctl execcommand is executed inside a virtual machine or container from the
/directory rather than from