Difference between revisions of "Basic operations in OpenVZ environment"
(VE, VPS -> container) |
(→Enter to and exit from the container: ve->container, formatting) |
||
Line 33: | Line 33: | ||
[host-node]# vzctl enter CTID | [host-node]# vzctl enter CTID | ||
entered into container CTID | entered into container CTID | ||
− | [ | + | [container]# |
</pre> | </pre> | ||
− | To exit from [[container]], just type <code>exit</code> and press | + | To exit from [[container]], just type <code>exit</code> and press Enter: |
<pre> | <pre> | ||
− | [ | + | [container]# exit |
exited from container VEID | exited from container VEID | ||
− | |||
[host-node]# | [host-node]# | ||
</pre> | </pre> |
Revision as of 09:08, 9 April 2008
This article assumes you have already installed OpenVZ and prepared the OS template cache(s). If not, follow the links to perform the steps needed.
Create and start a container
To create and start a container, run the following commands:
[host-node]# vzctl create CTID --ostemplate osname [host-node]# vzctl set CTID --ipadd a.b.c.d --save [host-node]# vzctl set CTID --nameserver a.b.c.d --save [host-node]# vzctl start CTID
Here CTID is the numeric ID for the container; osname is the name of the OS template for the container, and a.b.c.d is the IP address to be assigned to the container.
Example:
[host-node]# vzctl create 101 --ostemplate fedora-core-5-minimal [host-node]# vzctl set 101 --ipadd 10.1.2.3 --save [host-node]# vzctl set 101 --nameserver 10.0.2.1 --save [host-node]# vzctl start 101
Your freshly-created container should be up and running now; you can see its processes:
[host-node]# vzctl exec CTID ps ax
Enter to and exit from the container
To enter container give the following command:
[host-node]# vzctl enter CTID entered into container CTID [container]#
To exit from container, just type exit
and press Enter:
[container]# exit exited from container VEID [host-node]#
Stop and destroy the container
To stop container:
[host-node]# vzctl stop CTID Stopping container ... Container was stopped Container is unmounted
And to destroy container:
[host-node]# vzctl destroy CTID Destroying container private area: /vz/private/CTID Container private area was destroyed
Now, when you know how to manage your container, learn about Resource management.