Skip to content

Instantly share code, notes, and snippets.

@jedahan
Last active September 2, 2021 14:14
Show Gist options
  • Save jedahan/e716a938bb9fe4f9782bcf6ebb650ed9 to your computer and use it in GitHub Desktop.
Save jedahan/e716a938bb9fe4f9782bcf6ebb650ed9 to your computer and use it in GitHub Desktop.

Revisions

  1. jedahan revised this gist Sep 2, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion podman-desktop.bash
    Original file line number Diff line number Diff line change
    @@ -39,7 +39,7 @@ EOF | \
    --cpus 2 \
    --memory 2G \
    --disk 10G \
    --name podman \
    --name ${INSTANCE_NAME} \
    --cloud-init - \
    ${VERSION_ID}

  2. jedahan created this gist Sep 2, 2021.
    53 changes: 53 additions & 0 deletions podman-desktop.bash
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,53 @@
    #!/usr/bin/env bash
    set -e

    command -v multipass 2>/dev/null || die "missing multipass"
    command -v podman 2>/dev/null || die "missing podman"

    INSTANCE_NAME="podman"
    VERSION_ID="20.04"
    IDENTITY="${IDENTITY:-~/.ssh/id_rsa}"
    PUBKEYFILE=${PUBKEY:-${IDENTITY}.pub}
    MOUNTS=${MOUNTS:-/Users /Volumes /private /tmp /var/folders} # Docker Desktop Defaults

    test -f $IDENTITY || die "cannot find identity $IDENTITY"
    test -f $PUBKEYFILE || die "cannot find pubkey $PUBKEYFILE"
    PUBKEY=$(cat ${PUBKEYFILE})

    multipass set client.primary-name=$INSTANCE_NAME

    cat <<<EOF
    ---
    users:
    - name: ubuntu
    - ssh-authorized-keys: [ ${PUBKEY} ]

    apt:
    sources:
    libcontainers:
    source: "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /"

    package_upgrade: true
    packages: ['containerd', 'fuse-overlayfs', 'podman']

    runcmd:
    - systemctl --user enable --now podman.socket
    - sudo loginctl enable-linger $USER
    - sudo systemctl enable --now ssh.service
    EOF | \
    multipass launch \
    --cpus 2 \
    --memory 2G \
    --disk 10G \
    --name podman \
    --cloud-init - \
    ${VERSION_ID}

    IP=$(multipass info ${INSTANCE_NAME} | grep IPv4: | cut -d ':' -f2 | tr -ds ' ' '')

    podman system connection add $INSTANCE_NAME --identity "${IDENTITY}" ssh://ubuntu@"${IP}"/run/user/1000/podman/podman.sock

    for mount in $MOUNTS; do multipass mount "$mount" $INSTANCE_NAME; done

    multipass list
    podman system connection list