-
-
Save robotamer/2d4b0294f06c52e8c2fb2b5d09ec72f2 to your computer and use it in GitHub Desktop.
Revisions
-
robotamer revised this gist
Jan 29, 2023 . 1 changed file with 14 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ #### LXC is the userspace interface for the Linux kernel containment feature. LXD and lxc runs on top of LXC. LXC provides the basic functionality used under the hood by LXD. However, it should not be confused with the lxc CLI client tool provided by LXD. ___ ## Image ### List available images ``` @@ -20,22 +20,21 @@ lxc image alias list images: # lists user-friendly names lxc image delete 4117cf6a0442 ``` This will delete an image with fingerprint ID 4117cf6a0442. You can obtain the fingerprint ID of an image with the `lxc image list` command. ___ ## Container ### Storage ``` lxc storage -h # Storage help lxc storage list # Storage list ``` ___ ### Network ``` lxc network -h # Network help lxc network list # Network list ``` ___ ### Launch a container This creates and starts a container from a image. ``` @@ -57,6 +56,7 @@ lxc stop alpinecont [--force] # --force if it doesn't want to stop lxc restart alpinecont [--force] lxc pause alpinecont # SIGSTOP to all container processes ``` ___ ### List local containers ``` lxc list @@ -76,13 +76,13 @@ lxc list security.privileged=true # filter for properties S - Number of snapshots t - Type (persistent or ephemeral) ``` ___ ### Info on containers ``` lxc info -h # Show instance or server information lxc info CONTAINERNAME # detailed info about one container ``` ____ ### Rename ``` lxc move CONTAINERNAME NEWNAME @@ -102,8 +102,15 @@ Configuration settings can be saved as **profiles**. lxc exec CONTAINERNAME -- PROGRAM OPTIONS lxc exec CONTAINERNAME sh lxc exec CONATINERNAME --env KEY=VALUE PROGRAM # environment variable lxc exec CONATINERNAME sh # Enter any container sh shell lxc exec CONATINERNAME -- /bin/bash # Enter Debian container running bash shell lxc exec CONATINERNAME -- /bin/ash # Enter Alpine container running ash shell ``` This command runs the program in all the namespaces and cgroups of the container. The program must exist inside the container. ___ ### Access container files ``` lxc file pull CONTAINERNAME/etc/passwd /tmp/mypasswd -
robotamer revised this gist
Jan 29, 2023 . 1 changed file with 11 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,22 +21,21 @@ lxc image delete 4117cf6a0442 ``` This will delete an image with fingerprint ID 4117cf6a0442. You can obtain the fingerprint ID of an image with the `lxc image list` command. ## Container ### Storage ``` lxc storage -h # Storage help lxc storage list # Storage list ``` ### Network ``` lxc network -h # Network help lxc network list # Network list ``` ### Launch a container This creates and starts a container from a image. ``` @@ -63,7 +62,6 @@ lxc pause alpinecont # SIGSTOP to all container processes lxc list lxc list --columns "nsapt" # name, status, arch, PID of init, type lxc list security.privileged=true # filter for properties ``` #### Available columns for the list command ``` @@ -78,6 +76,13 @@ lxc info CONTAINERNAME # detailed info about one container S - Number of snapshots t - Type (persistent or ephemeral) ``` ### Info on containers ``` lxc info -h # Show instance or server information lxc info CONTAINERNAME # detailed info about one container ``` ### Rename ``` lxc move CONTAINERNAME NEWNAME -
robotamer revised this gist
Jan 29, 2023 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,6 +28,12 @@ lxc storage -h # Storage help lxc storage list # Storage list ``` ## Network ``` lxc network -h # Network help lxc network list # Network list ``` ## Container -
robotamer revised this gist
Jan 29, 2023 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -21,6 +21,14 @@ lxc image delete 4117cf6a0442 ``` This will delete an image with fingerprint ID 4117cf6a0442. You can obtain the fingerprint ID of an image with the `lxc image list` command. ## Storage ``` lxc storage -h # Storage help lxc storage list # Storage list ``` ## Container ### Launch a container -
robotamer revised this gist
Jan 28, 2023 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,11 @@ # Useful LXD commands #### LXD is a system container manager. #### lxc is the LXD CLI client tool. #### LXC is the userspace interface for the Linux kernel containment feature. LXD and lxc runs on top of LXC. LXC provides the basic functionality used under the hood by LXD. However, it should not be confused with the lxc CLI client tool provided by LXD. ## Image ### List available images ``` -
robotamer revised this gist
Jan 28, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ This will delete an image with fingerprint ID 4117cf6a0442. You can obtain the f ## Container ### Launch a container This creates and starts a container from a image. ``` lxc launch ubuntu:14.04 CONTAINERNAME # image and container names are optional lxc launch ubuntu:14.04/armhf armcont # specific architecture -
robotamer revised this gist
Jan 28, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,7 +13,7 @@ lxc image alias list images: # lists user-friendly names ``` lxc image delete 4117cf6a0442 ``` This will delete an image with fingerprint ID 4117cf6a0442. You can obtain the fingerprint ID of an image with the `lxc image list` command. ## Container -
robotamer revised this gist
Jan 28, 2023 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,15 @@ # Useful LXD commands ## Image ### List available images ``` lxc image list # local images lxc image list ubuntu: # ubuntu: is officially supported image source lxc image list images: # images: is an unsupported source lxc image alias list images: # lists user-friendly names ``` ### Delete local image ``` lxc image delete 4117cf6a0442 ``` -
robotamer revised this gist
Jan 28, 2023 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,4 @@ # Useful LXD commands ## Image ### List available containers @@ -17,6 +14,7 @@ lxc image delete 4117cf6a0442 ``` This will delete an image with fingerprint ID 4117cf6a0442. You can obtain the fingerprint ID of an image with the sudo lxc image list command. ## Container ### Launch a container This creates and starts a container. -
robotamer revised this gist
Jan 28, 2023 . 1 changed file with 9 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,12 +3,21 @@ Summarized from https://stgraber.org/2016/03/19/lxd-2-0-your-first-lxd-container Interestingly, the LXD command line client is named.... `lxc`! ## Image ### List available containers ``` lxc image list # local images lxc image list ubuntu: # ubuntu: is officially supported image source lxc image list images: # images: is an unsupported source lxc image alias list images: # lists user-friendly names ``` ``` lxc image delete 4117cf6a0442 ``` This will delete an image with fingerprint ID 4117cf6a0442. You can obtain the fingerprint ID of an image with the sudo lxc image list command. ### Launch a container This creates and starts a container. ``` -
berndbausch revised this gist
Feb 28, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,7 +70,7 @@ lxc exec CONTAINERNAME -- PROGRAM OPTIONS lxc exec CONTAINERNAME sh lxc exec CONATINERNAME --env KEY=VALUE PROGRAM # environment variable ``` This command runs the program in all the namespaces and cgroups of the container. The program must exist inside the container. ### Access container files ``` lxc file pull CONTAINERNAME/etc/passwd /tmp/mypasswd -
berndbausch revised this gist
Feb 28, 2018 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,19 +10,20 @@ lxc image list images: # images: is an unsupported source lxc image alias list images: # lists user-friendly names ``` ### Launch a container This creates and starts a container. ``` lxc launch ubuntu:14.04 CONTAINERNAME # image and container names are optional lxc launch ubuntu:14.04/armhf armcont # specific architecture lxc launch images:alpine/3.3/amd64 # unsupported images: source ``` #### Create container Without starting it. ``` lxc init images:alpine/3.3/amd64 alpinecont lxc copy CONTAINER1 CONTAINER2 # clone lxc delete alpinecont [--force] # --force if it is running ``` #### Start/stop after creating it ``` lxc start alpinecont lxc stop alpinecont [--force] # --force if it doesn't want to stop @@ -36,7 +37,7 @@ lxc list --columns "nsapt" # name, status, arch, PID of init, type lxc list security.privileged=true # filter for properties lxc info CONTAINERNAME # detailed info about one container ``` #### Available columns for the list command ``` 4 - IPv4 address 6 - IPv6 address @@ -54,7 +55,7 @@ lxc info CONTAINERNAME # detailed info about one container lxc move CONTAINERNAME NEWNAME ``` ### Configuration Config changes are effective immediately, even if container is running. ``` export VISUAL=/usr/bin/vim lxc config edit CONTAINERNAME # launches editor -
berndbausch revised this gist
Feb 28, 2018 . 1 changed file with 37 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,9 +16,10 @@ lxc launch ubuntu:14.04 CONTAINERNAME # image and container names are optiona lxc launch ubuntu:14.04/armhf armcont # specific architecture lxc launch images:alpine/3.3/amd64 # unsupported images: source ``` #### Create containers ``` lxc init images:alpine/3.3/amd64 alpinecont lxc copy CONTAINER1 CONTAINER2 # clone lxc delete alpinecont [--force] # --force if it is running ``` #### start/stop after creating it @@ -48,3 +49,38 @@ lxc info CONTAINERNAME # detailed info about one container S - Number of snapshots t - Type (persistent or ephemeral) ``` ### Rename ``` lxc move CONTAINERNAME NEWNAME ``` ### Configuration Changes are effective immediately, even if container is running. ``` export VISUAL=/usr/bin/vim lxc config edit CONTAINERNAME # launches editor lxc config set CONTAINERNAME KEY VALUE # change a single config item lxc config device add CONTAINERNAME DEVICE TYPE KEY=VALUE lxc config show [--expanded] CONTAINERNAME Configuration settings can be saved as **profiles**. ``` ### Enter the container ``` lxc exec CONTAINERNAME -- PROGRAM OPTIONS lxc exec CONTAINERNAME sh lxc exec CONATINERNAME --env KEY=VALUE PROGRAM # environment variable ``` The program must exist inside the container. This command runs the program in all the namespaces and cgroups of the container. ### Access container files ``` lxc file pull CONTAINERNAME/etc/passwd /tmp/mypasswd lxc file push /tmp/mypasswd CONTAINERNAME/etc/passwd lxc file edit CONTAINERNAME/etc/passwd ``` ### Snapshots ``` lxc snapshot CONTAINERNAME SNAPNAME # SNAPNAME is optional; default name snap*X* lxc restore CONTAINERNAME SNAPNAME # resets the container to snapshot lxc copy CONTAINERNAME/SNAPNAME NEWCONTAINER # new container from snapshot lxc delete CONTAINERNAME/SNAPNAME lxc info CONTAINERNAME # lists snapshots among other info lxc move CONTAINERNAME/SNAPNAME CONTAINERNAME/NEWSNAPNAME # rename snapshot -
berndbausch created this gist
Feb 28, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,50 @@ # Useful LXD commands Summarized from https://stgraber.org/2016/03/19/lxd-2-0-your-first-lxd-container-312/. Interestingly, the LXD command line client is named.... `lxc`! ### List available containers ``` lxc image list ubuntu: # ubuntu: is officially supported image source lxc image list images: # images: is an unsupported source lxc image alias list images: # lists user-friendly names ``` ### Launch a container #### create and start it ``` lxc launch ubuntu:14.04 CONTAINERNAME # image and container names are optional lxc launch ubuntu:14.04/armhf armcont # specific architecture lxc launch images:alpine/3.3/amd64 # unsupported images: source ``` #### only create it, and delete it ``` lxc init images:alpine/3.3/amd64 alpinecont lxc delete alpinecont [--force] # --force if it is running ``` #### start/stop after creating it ``` lxc start alpinecont lxc stop alpinecont [--force] # --force if it doesn't want to stop lxc restart alpinecont [--force] lxc pause alpinecont # SIGSTOP to all container processes ``` ### List local containers ``` lxc list lxc list --columns "nsapt" # name, status, arch, PID of init, type lxc list security.privileged=true # filter for properties lxc info CONTAINERNAME # detailed info about one container ``` #### available columns for the list command ``` 4 - IPv4 address 6 - IPv6 address a - Architecture c - Creation date n - Name p - PID of the container's init process P - Profiles s - State S - Number of snapshots t - Type (persistent or ephemeral) ```