0% found this document useful (0 votes)
4 views

LXC Commands

Uploaded by

ge01109
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

LXC Commands

Uploaded by

ge01109
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

LXC / LXD Commands

apt install lxd lxd-client Installs LXC


lxc init Starts LXC / Initial configuration
lxc launch images:alpine/3.9 mycontainer Loads the image Alpine from the repository
“images” in version 3.9 and names it
“mycontainer”
lxc image list Lists all available images
lxc list Lists all running and stopped containers
lxc exec mycontainer -- ash Logs in with ash on the "mycontainer"
container
lxc stop mycontainer Stops the container "mycontainer"
lxc delete mycontainer Deletes the stopped container "mycontainer"
lxc delete --force mycontainer Deletes the still running container
"mycontainer"
lxc image delete myimage Deletes the image "myimage"
lxc image copy images:alpine/3.9 local: -- Copy the image "Alpine" from the repository
alias mynalpine "images" in version 3.9 into the local storage
and name it "myalpine"
lxc launch myalpine nginx Starts the "myalpine" container under the
name "nginx"
lxc launch myalpine Starts the "myalpine" container and uses a
random name
lxc exec nginx -- apk update Updates the Alpine package sources for the
“nginx” container
lxc exec nginx -- apk add nginx Installs nginx in the "nginx" container
lxc file edit Edits the default.conf file of the nginx web
nginx/etc/nginx/conf.d/default.conf server of the “nginx” container
lxc file push index.html Copies a previously created index.html file into
nginx/var/www/index.html the “nginx” container at the appropriate
location
lxc snapshot nginx 1.0 Creates a snapshot of the nginx container and
names it 1.0
lxc restore nginx 1.0 Uses Snapshot 1.0 to restore the container
lxc info nginx Shows detailed information about the nginx
container
lxc delete nginx/1.0 Deletes snapshot 1.0 of the "nginx" container
lxc copy nginx/1.0 nginx2 Creates a container nginx2 that is a copy of
snapshot 1.0
lxc start nginx2 Starts the container nginx2
lxc move nginx2 nginx3 Renames the container from nginx2 to nginx3
lxc remote list Displays the remote repositories
lxc config set Configures an LXC environment
lxc config set core.https_address Specifies which HTTPS port LXC should listen
„[::]:8443“ on
lxc config set core.trust_password secret Defines a “secret” password for the LXC server
lxc remote add remoteserver Enables the server with the IP address
172.31.23.109:8443 --password=secret 172.31.23.109 as a remote server under the
name “remoteserver” and uses the password
“secret”
lxc publish nginx/1.0 --alias meinnginx- Releases a new image called “meinnginx-
alpine alpine” from Snapshot 1.0
lxc image list images: Shows the images of the repository "images"
lxc image list images: | grep debian Shows the Debian images of the repository
"images"
lxc publish web/snapshot01 --alias Creates a new image from the snapshot
web_neu "snapshot01" of the container "web" and calls
it "web_new"
lxc image export web webtest/ Exports the "web" image to the "webtest"
directory
lxc image import image.tar.gz --alias Imports image.tar.gz and gives the new image
nginx5 the name nginx5
lxc config set ubuntu16 limits.memory Limits the main memory of the container
512MB ubuntu16 to 512MB
lxc config set ubuntu16 limits.cpu 2 Limits the CPU cores of the Ubuntu16 container
to 2
lxc storage list Lists the storage pools
lxc storage edit storage1 Edits the yaml file of the storage pool storage1
lxc storage create storage2 dir Creates the storage pool storage2 of type
directory (dir)
lxc storage create zfs-storage zfs Creates the storage pool zfs-storage of the
source=/dev/sdb type zfs and uses the HDD / dev / sdb for it
lxc storage show zfs-storage Shows details of the zfs-storage storage pool
lxc launch nginx5 webserver --storage Starts the image nginx5 in the storage pool
storage2 storage2 and gives it the name webserver
lxc list -c -c makes other columns usable
lxc list -c ns46tSb standard lxc container list expanded with
option b, which shows in which storage pool
the respective container is stored

You might also like