Editing
Main Page
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== LX Docker === steps # run image on docker (same arch) # find docker CMD # check existing lx zones # create lx zone # export docker fs (tar) # replace lx zone's root fs with docker fs (tar) # start lx zone ==== lxcreate script --> ==== <syntaxhighlight lang="bash" copy class="mw-collapsible mw-collapsed"> #!/bin/sh # Check if alias and ip are provided as arguments if [ -z "$2" ]; then echo "Usage: $0 <alias> <ip> <env> [mem=64] [swap=256] [image_uuid=0b7d45d9-be8c-439f-9a24-bd6223199c2b]" echo "NOTE: alias is used for docker image, by default alias:latest is used" echo "IE: docker run alias:latest" echo "ex: $0 mediawiki 192.168.3.123/24" echo "ex: $0 mediawiki 192.168.3.123/24 NODE_ENV=development" echo "ex: $0 mediawiki 192.168.3.123/24 NODE_ENV=development 128 256" exit 1 fi # Assign arguments to variables alias="$1" ip="$2" env="$3" mem="${4:-64}" # Default to 64 if mem not provided swap="${5:-256}" # Default to 256 if swap not provided #image_uuid=$(imgadm avail -H -o uuid name=~alpine type=~lx | tail -n1) # Default to latest alpine lx #image_uuid="${8:-$(imgadm avail -H -o uuid name=~alpine type=~lx | tail -n1)}" # Default to alpine 2025-01-20 image_uuid="${6:-0b7d45d9-be8c-439f-9a24-bd6223199c2b}" image=$(imgadm list -H -o uuid uuid=~0b7d45d9-be8c-439f-9a24-bd6223199c2b) if [ -z "$image" ]; then imgadm import $image_uuid fi # Basic IP CIDR validation (eg, 192.168.3.123/24) if ! echo "$ip" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/[0-9]+$'; then echo "Error: IP must be in CIDR format (e.g., 192.168.3.123/24) or 'dhcp'" exit 1 fi echo "Fetching $alias:latest..." if [ -z "$env" ]; then ssh apod "podman run -d --rm --name $alias $alias:latest" else ssh apod "podman run -d --rm --name $alias -e $env $alias:latest" fi dir=$(ssh apod "podman inspect $alias | jq -r '.[0].Config | .WorkingDir'") env=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Env'" | tr -s '\n' ' ' | sed 's/"/\\"/g') cmd=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Cmd'" | tr -s '\n' ' ' | sed 's/"/\\"/g') entry=$(ssh apod "podman inspect $alias | jq -r '.[0].Config.Entrypoint'" | tr -s '\n' ' ' | sed 's/"/\\"/g') vmadm create << EOF { "brand": "lx", "kernel_version": "5.15", "autoboot": true, "docker": true, "internal_metadata": { "docker:workingdir": "${dir}", "docker:env": "${env}", "docker:cmd": "${cmd}", "docker:entrypoint": "${entry}" }, "image_uuid": "${image_uuid}", "alias": "${alias}","hostname": "${alias}", "max_physical_memory": ${mem}, "max_swap": ${swap}, "resolvers": ["1.1.1.1"], "nics": [ { "nic_tag": "admin", "gateway": "192.168.3.1", "ips": ["${ip}"] } ] } EOF uuid=$(vmadm list -H -o uuid alias=$alias) rm -rf /zones/$uuid/root mkdir /zones/$uuid/root echo "Transferring image..." ssh -C apod "podman export $alias" | tar xpf - -C /zones/$uuid/root 2>/dev/null vmadm start $uuid && \ ssh apod "podman stop $alias" </syntaxhighlight> ==== lxcreate ==== <pre> [root@smartos ~]# /zones/lxcreate Usage: ./lxcreate <alias> <ip> <env> [mem=64] [swap=256] [image_uuid=0b7d45d9-be8c-439f-9a24-bd6223199c2b] NOTE: alias is used for docker image, by default alias:latest is used IE: docker run alias:latest ex: ./lxcreate mediawiki 192.168.3.123/24 ex: ./lxcreate ghost 192.168.3.123/24 NODE_ENV=development ex: ./lxcreate ghost 192.168.3.123/24 NODE_ENV=development 128 256</pre> ==== mediawiki ==== <pre> [root@smartos ~]# /zones/lxcreate mediawiki 192.168.3.123/24 Fetching mediawiki:latest... 5edd70c248cfb94b5e46b3d771b0f2dfc7a067c54619f0871dfd24b2f063a86a Successfully created VM fb9d0fe9-c34e-4c51-8b4e-19820257935b Transferring image... Successfully started VM fb9d0fe9-c34e-4c51-8b4e-19820257935b mediawiki </pre> ==== ghost ==== sometimes you need to set environment variables (https://hub.docker.com/_/ghost) <pre> $ podman run -d --name some-ghost -e NODE_ENV=development ghost </pre> <pre> [root@smartos ~]# vm-create ghost 192.168.3.123/24 NODE_ENV=development Successfully created VM 7ceaeea2-7bc4-4e89-ab3f-da516982548b </pre> sometimes you need to delete/edit the entrypoint <syntaxhighlight copy> alias=ghost uuid=$(vmadm list -H -o uuid alias=$alias) sed -i '.orig' '/entrypoint/d' /zones/$uuid/config/metadata.json # not sure why, but this was needed (cd /zones/$uuid/root/var/lib/ghost; mv content content.del; mv content.orig content) vmadm reboot $uuid # </syntaxhighlight> <pre> [root@smartos ~]# alias=ghost [root@smartos ~]# uuid=$(vmadm list -H -o uuid alias=$alias) [root@smartos ~]# vmadm get $uuid | grep entry "docker:entrypoint": "[ \"docker-entrypoint.sh\" ] ", [root@smartos ~]# echo '#!/bin/bash cd /var/lib/ghost gosu node node current/index.js ' > $(find /zones/$uuid -name docker-entrypoint.sh 2> /dev/null) </pre> not sure why, but this was needed <pre> [root@smartos ~]# (cd /zones/$uuid/root/var/lib/ghost; mv content content.del; mv content.orig content) </pre>
Summary:
Please note that all contributions to pega.life may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Pega.life:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Main Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information