[Unit] Description=Ubuntu Pet Container After=network-online.target Wants=network-online.target [Service] Environment="CONTAINER=ubuntu-pet" Environment="IMAGE=ubuntu-ryan" Environment="SSH_PORT=2222" Environment="MOSH_PORTS=60000-60010" TimeoutStartSec=0 ExecStartPre=-/bin/podman kill ${CONTAINER} ExecStartPre=-/bin/podman rm ${CONTAINER} ExecStartPre=-/bin/sh -c "[[ $IMAGE =~ '/' ]] && podman pull ${IMAGE}" ExecStartPre=mkdir -p ${HOME}/.ssh/${CONTAINER}/root ExecStartPre=touch ${HOME}/.ssh/${CONTAINER}/root/authorized_keys ExecStartPre=chmod 600 ${HOME}/.ssh/${CONTAINER}/root/authorized_keys ExecStart=/bin/podman run --name ${CONTAINER} --hostname ${CONTAINER} --rm -p ${SSH_PORT}:22 -p ${MOSH_PORTS}:${MOSH_PORTS}/udp -v ${HOME}/.ssh/${CONTAINER}:/etc/ssh/keys:Z ${IMAGE} [Install] WantedBy=default.target