diff --git a/.github/workflows/automatic-doc-checks.yml b/.github/workflows/automatic-doc-checks.yml new file mode 100644 index 0000000000..fd839dcd88 --- /dev/null +++ b/.github/workflows/automatic-doc-checks.yml @@ -0,0 +1,22 @@ +# +name: Automatic doc checks + +on: + push: + branches: [ main ] + pull_request: + + workflow_dispatch: + # Manual trigger + + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + documentation-checks: + uses: canonical/documentation-workflows/.github/workflows/documentation-checks.yaml@main + with: + working-directory: "./docs" + fetch-depth: 0 diff --git a/docs/.custom_wordlist.txt b/docs/.custom_wordlist.txt new file mode 100644 index 0000000000..b793c4a013 --- /dev/null +++ b/docs/.custom_wordlist.txt @@ -0,0 +1,21 @@ +# Leave a blank line at the end of this file to support concatenation +cjk +cryptographically +dvipng +fonts +freefont +github +GPG +gyre +https +lang +latexmk +otf +plantuml +tex +texlive +TOC +utils +WCAG +xetex +xindy diff --git a/docs/.gitignore b/docs/.gitignore new file mode 100644 index 0000000000..cc5c727a05 --- /dev/null +++ b/docs/.gitignore @@ -0,0 +1,15 @@ +/*env*/ + +.sphinx/venv/ +.sphinx/requirements.txt +.sphinx/warnings.txt +.sphinx/.wordlist.dic +.sphinx/.doctrees/ +.sphinx/node_modules/ + +package*.json +_build +.DS_Store +__pycache__ +.idea/ +.vscode/ diff --git a/docs/.readthedocs.yaml b/docs/.readthedocs.yaml new file mode 100644 index 0000000000..3cc15b0a44 --- /dev/null +++ b/docs/.readthedocs.yaml @@ -0,0 +1,30 @@ +# .readthedocs.yaml +# Read the Docs configuration file +# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details + +# Required +version: 2 + +# Set the version of Python and other tools you might need +build: + os: ubuntu-22.04 + tools: + python: "3.11" + jobs: + pre_install: + - git fetch --unshallow || true + +# Build documentation in the docs/ directory with Sphinx +sphinx: + builder: dirhtml + configuration: docs/conf.py + fail_on_warning: true + +# If using Sphinx, optionally build your docs in additional formats such as PDF +formats: +- pdf + +# Optionally declare the Python requirements required to build your docs +python: + install: + - requirements: docs/.sphinx/requirements.txt diff --git a/docs/.sphinx/.markdownlint.json b/docs/.sphinx/.markdownlint.json new file mode 100644 index 0000000000..f42753f268 --- /dev/null +++ b/docs/.sphinx/.markdownlint.json @@ -0,0 +1,27 @@ +{ + "default": false, + "MD003": { + "style": "atx" + }, + "MD013": { + "code_blocks": false, + "tables": false, + "stern": true, + "line_length": 150 + }, + "MD014": true, + "MD018": true, + "MD022": true, + "MD023": true, + "MD026": { + "punctuation": ".,;。,;" + }, + "MD031": { + "list_items": false + }, + "MD032": true, + "MD035": true, + "MD042": true, + "MD045": true, + "MD052": true +} \ No newline at end of file diff --git a/docs/.sphinx/.wordlist.txt b/docs/.sphinx/.wordlist.txt new file mode 100644 index 0000000000..be5021a1f6 --- /dev/null +++ b/docs/.sphinx/.wordlist.txt @@ -0,0 +1,64 @@ +ACME +ACME's +addons +AGPLv +API +APIs +balancer +Charmhub +CLI +DCO +Diátaxis +Dqlite +dropdown +EBS +EKS +enablement +favicon +Furo +Git +GitHub +Grafana +IAM +installable +JSON +Juju +Kubeflow +Kubernetes +Launchpad +linter +LTS +LXD +Makefile +Makefiles +Matrix +Mattermost +MicroCeph +MicroCloud +MicroOVN +MyST +namespace +namespaces +NodePort +Numbat +observability +OEM +OLM +Permalink +pre +Quickstart +ReadMe +reST +reStructuredText +roadmap +RTD +subdirectories +subfolders +subtree +TODO +Ubuntu +UI +UUID +VM +webhook +YAML diff --git a/docs/.sphinx/_static/css/pdf.css b/docs/.sphinx/_static/css/pdf.css new file mode 100644 index 0000000000..f9e28dd2df --- /dev/null +++ b/docs/.sphinx/_static/css/pdf.css @@ -0,0 +1,15 @@ +/* Only relevant for specific PDF generation issues */ + +.rubric>.hclass2 { + display: block; + font-size: 2em; + border-radius: .5rem; + font-weight: 300; + line-height: 1.25; + margin-top: 1.75rem; + margin-right: -0.5rem; + margin-bottom: 0.5rem; + margin-left: -0.5rem; + padding-left: .5rem; + padding-right: .5rem; +} \ No newline at end of file diff --git a/docs/.sphinx/_static/favicon.png b/docs/.sphinx/_static/favicon.png new file mode 100644 index 0000000000..7f175e4617 Binary files /dev/null and b/docs/.sphinx/_static/favicon.png differ diff --git a/docs/.sphinx/_static/tag.png b/docs/.sphinx/_static/tag.png new file mode 100644 index 0000000000..f6f6e5aa4b Binary files /dev/null and b/docs/.sphinx/_static/tag.png differ diff --git a/docs/.sphinx/_templates/header.html b/docs/.sphinx/_templates/header.html new file mode 100644 index 0000000000..f9848fe071 --- /dev/null +++ b/docs/.sphinx/_templates/header.html @@ -0,0 +1,52 @@ + \ No newline at end of file diff --git a/docs/.sphinx/fonts/LICENCE.txt b/docs/.sphinx/fonts/LICENCE.txt new file mode 100644 index 0000000000..ae78a8f94e --- /dev/null +++ b/docs/.sphinx/fonts/LICENCE.txt @@ -0,0 +1,96 @@ +------------------------------- +UBUNTU FONT LICENCE Version 1.0 +------------------------------- + +PREAMBLE +This licence allows the licensed fonts to be used, studied, modified and +redistributed freely. The fonts, including any derivative works, can be +bundled, embedded, and redistributed provided the terms of this licence +are met. The fonts and derivatives, however, cannot be released under +any other licence. The requirement for fonts to remain under this +licence does not require any document created using the fonts or their +derivatives to be published under this licence, as long as the primary +purpose of the document is not to be a vehicle for the distribution of +the fonts. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this licence and clearly marked as such. This may +include source files, build scripts and documentation. + +"Original Version" refers to the collection of Font Software components +as received under this licence. + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to +a new environment. + +"Copyright Holder(s)" refers to all individuals and companies who have a +copyright ownership of the Font Software. + +"Substantially Changed" refers to Modified Versions which can be easily +identified as dissimilar to the Font Software by users of the Font +Software comparing the Original Version with the Modified Version. + +To "Propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification and with or without charging +a redistribution fee), making available to the public, and in some +countries other activities as well. + +PERMISSION & CONDITIONS +This licence does not grant any rights under trademark law and all such +rights are reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of the Font Software, to propagate the Font Software, subject to +the below conditions: + +1) Each copy of the Font Software must contain the above copyright +notice and this licence. These can be included either as stand-alone +text files, human-readable headers or in the appropriate machine- +readable metadata fields within text or binary files as long as those +fields can be easily viewed by the user. + +2) The font name complies with the following: +(a) The Original Version must retain its name, unmodified. +(b) Modified Versions which are Substantially Changed must be renamed to +avoid use of the name of the Original Version or similar names entirely. +(c) Modified Versions which are not Substantially Changed must be +renamed to both (i) retain the name of the Original Version and (ii) add +additional naming elements to distinguish the Modified Version from the +Original Version. The name of such Modified Versions must be the name of +the Original Version, with "derivative X" where X represents the name of +the new work, appended to that name. + +3) The name(s) of the Copyright Holder(s) and any contributor to the +Font Software shall not be used to promote, endorse or advertise any +Modified Version, except (i) as required by this licence, (ii) to +acknowledge the contribution(s) of the Copyright Holder(s) or (iii) with +their explicit written permission. + +4) The Font Software, modified or unmodified, in part or in whole, must +be distributed entirely under this licence, and must not be distributed +under any other licence. The requirement for fonts to remain under this +licence does not affect any document created using the Font Software, +except any version of the Font Software extracted from a document +created using the Font Software may only be distributed under this +licence. + +TERMINATION +This licence becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF +COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER +DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/.sphinx/fonts/Ubuntu-B.ttf b/docs/.sphinx/fonts/Ubuntu-B.ttf new file mode 100644 index 0000000000..b173da2741 Binary files /dev/null and b/docs/.sphinx/fonts/Ubuntu-B.ttf differ diff --git a/docs/.sphinx/fonts/Ubuntu-R.ttf b/docs/.sphinx/fonts/Ubuntu-R.ttf new file mode 100644 index 0000000000..d748728a20 Binary files /dev/null and b/docs/.sphinx/fonts/Ubuntu-R.ttf differ diff --git a/docs/.sphinx/fonts/Ubuntu-RI.ttf b/docs/.sphinx/fonts/Ubuntu-RI.ttf new file mode 100644 index 0000000000..4f2d2bc7cb Binary files /dev/null and b/docs/.sphinx/fonts/Ubuntu-RI.ttf differ diff --git a/docs/.sphinx/fonts/UbuntuMono-B.ttf b/docs/.sphinx/fonts/UbuntuMono-B.ttf new file mode 100644 index 0000000000..7bd6665765 Binary files /dev/null and b/docs/.sphinx/fonts/UbuntuMono-B.ttf differ diff --git a/docs/.sphinx/fonts/UbuntuMono-R.ttf b/docs/.sphinx/fonts/UbuntuMono-R.ttf new file mode 100644 index 0000000000..fdd309d716 Binary files /dev/null and b/docs/.sphinx/fonts/UbuntuMono-R.ttf differ diff --git a/docs/.sphinx/fonts/UbuntuMono-RI.ttf b/docs/.sphinx/fonts/UbuntuMono-RI.ttf new file mode 100644 index 0000000000..18f81a2925 Binary files /dev/null and b/docs/.sphinx/fonts/UbuntuMono-RI.ttf differ diff --git a/docs/.sphinx/get_vale_conf.py b/docs/.sphinx/get_vale_conf.py new file mode 100644 index 0000000000..9ee2d0b5f6 --- /dev/null +++ b/docs/.sphinx/get_vale_conf.py @@ -0,0 +1,53 @@ +#! /usr/bin/env python + +import requests +import os + +DIR = os.getcwd() + + +def main(): + if os.path.exists(f"{DIR}/.sphinx/styles/Canonical"): + print("Vale directory exists") + else: + os.makedirs(f"{DIR}/.sphinx/styles/Canonical") + + url = ( + "https://api.github.com/repos/canonical/praecepta/" + + "contents/styles/Canonical" + ) + r = requests.get(url) + for item in r.json(): + download = requests.get(item["download_url"]) + file = open(".sphinx/styles/Canonical/" + item["name"], "w") + file.write(download.text) + file.close() + + if os.path.exists(f"{DIR}/.sphinx/styles/config/vocabularies/Canonical"): + print("Vocab directory exists") + else: + os.makedirs(f"{DIR}/.sphinx/styles/config/vocabularies/Canonical") + + url = ( + "https://api.github.com/repos/canonical/praecepta/" + + "contents/styles/config/vocabularies/Canonical" + ) + r = requests.get(url) + for item in r.json(): + download = requests.get(item["download_url"]) + file = open( + ".sphinx/styles/config/vocabularies/Canonical/" + item["name"], + "w" + ) + file.write(download.text) + file.close() + config = requests.get( + "https://raw.githubusercontent.com/canonical/praecepta/main/vale.ini" + ) + file = open(".sphinx/vale.ini", "w") + file.write(config.text) + file.close() + + +if __name__ == "__main__": + main() diff --git a/docs/.sphinx/images/Canonical-logo-4x.png b/docs/.sphinx/images/Canonical-logo-4x.png new file mode 100644 index 0000000000..fd75696eb5 Binary files /dev/null and b/docs/.sphinx/images/Canonical-logo-4x.png differ diff --git a/docs/.sphinx/images/front-page-light.pdf b/docs/.sphinx/images/front-page-light.pdf new file mode 100644 index 0000000000..bb68cdf8f5 Binary files /dev/null and b/docs/.sphinx/images/front-page-light.pdf differ diff --git a/docs/.sphinx/images/normal-page-footer.pdf b/docs/.sphinx/images/normal-page-footer.pdf new file mode 100644 index 0000000000..dfd73cbc7e Binary files /dev/null and b/docs/.sphinx/images/normal-page-footer.pdf differ diff --git a/docs/.sphinx/latex_elements_template.txt b/docs/.sphinx/latex_elements_template.txt new file mode 100644 index 0000000000..322412c7de --- /dev/null +++ b/docs/.sphinx/latex_elements_template.txt @@ -0,0 +1,119 @@ +{ + 'papersize': 'a4paper', + 'pointsize': '11pt', + 'fncychap': '', + 'preamble': r''' +%\usepackage{charter} +%\usepackage[defaultsans]{lato} +%\usepackage{inconsolata} +\setmainfont[UprightFont = *-R, BoldFont = *-B, ItalicFont=*-RI, Extension = .ttf]{Ubuntu} +\setmonofont[UprightFont = *-R, BoldFont = *-B, ItalicFont=*-RI, Extension = .ttf]{UbuntuMono} +\usepackage[most]{tcolorbox} +\tcbuselibrary{breakable} +\usepackage{lastpage} +\usepackage{tabto} +\usepackage{ifthen} +\usepackage{etoolbox} +\usepackage{fancyhdr} +\usepackage{graphicx} +\usepackage{titlesec} +\usepackage{fontspec} +\usepackage{tikz} +\usepackage{changepage} +\usepackage{array} +\usepackage{tabularx} +\definecolor{yellowgreen}{RGB}{154, 205, 50} +\definecolor{title}{RGB}{76, 17, 48} +\definecolor{subtitle}{RGB}{116, 27, 71} +\definecolor{label}{RGB}{119, 41, 100} +\definecolor{copyright}{RGB}{174, 167, 159} +\makeatletter +\def\tcb@finalize@environment{% + \color{.}% hack for xelatex + \tcb@layer@dec% +} +\makeatother +\newenvironment{sphinxclassprompt}{\color{yellowgreen}\setmonofont[Color = 9ACD32, UprightFont = *-R, Extension = .ttf]{UbuntuMono}}{} +\tcbset{enhanced jigsaw, colback=black, fontupper=\color{white}} +\newtcolorbox{termbox}{use color stack, breakable, colupper=white, halign=flush left} +\newenvironment{sphinxclassterminal}{\setmonofont[Color = white, UprightFont = *-R, Extension = .ttf]{UbuntuMono}\sphinxsetup{VerbatimColor={black}}\begin{termbox}}{\end{termbox}} +\newcommand{\dimtorightedge}{% + \dimexpr\paperwidth-1in-\hoffset-\oddsidemargin\relax} +\newcommand{\dimtotop}{% + \dimexpr\height-1in-\voffset-\topmargin-\headheight-\headsep\relax} +\newtoggle{tpage} +\AtBeginEnvironment{titlepage}{\global\toggletrue{tpage}} +\fancypagestyle{plain}{ + \fancyhf{} + \fancyfoot[R]{\thepage\ of \pageref*{LastPage}} + \renewcommand{\headrulewidth}{0pt} + \renewcommand{\footrulewidth}{0pt} +} +\fancypagestyle{normal}{ + \fancyhf{} + \fancyfoot[R]{\thepage\ of \pageref*{LastPage}} + \renewcommand{\headrulewidth}{0pt} + \renewcommand{\footrulewidth}{0pt} +} +\fancypagestyle{titlepage}{% + \fancyhf{} + \fancyfoot[L]{\footnotesize \textcolor{copyright}{© 2024 Canonical Ltd. All rights reserved.}} +} +\newcommand\sphinxbackoftitlepage{\thispagestyle{titlepage}} +\titleformat{\chapter}[block]{\Huge \color{title} \bfseries\filright}{\thechapter .}{1.5ex}{} +\titlespacing{\chapter}{0pt}{0pt}{0pt} +\titleformat{\section}[block]{\huge \bfseries\filright}{\thesection .}{1.5ex}{} +\titlespacing{\section}{0pt}{0pt}{0pt} +\titleformat{\subsection}[block]{\Large \bfseries\filright}{\thesubsection .}{1.5ex}{} +\titlespacing{\subsection}{0pt}{0pt}{0pt} +\setcounter{tocdepth}{1} +\renewcommand\pagenumbering[1]{} +''', + 'sphinxsetup': 'verbatimwithframe=false, pre_border-radius=0pt, verbatimvisiblespace=\\phantom{}, verbatimcontinued=\\phantom{}', + 'extraclassoptions': 'openany,oneside', + 'maketitle': r''' +\begin{titlepage} +\begin{flushleft} + \begin{tikzpicture}[remember picture,overlay] + \node[anchor=south east, inner sep=0] at (current page.south east) { + \includegraphics[width=\paperwidth, height=\paperheight]{front-page-light} + }; + \end{tikzpicture} +\end{flushleft} + +\vspace*{3cm} + +\begin{adjustwidth}{8cm}{0pt} +\begin{flushleft} + \huge \textcolor{black}{\textbf{}{\raggedright{$PROJECT}}} +\end{flushleft} +\end{adjustwidth} + +\vfill + +\begin{adjustwidth}{8cm}{0pt} +\begin{tabularx}{0.5\textwidth}{ l l } + \textcolor{lightgray}{© 2024 Canonical Ltd.} & \hspace{3cm} \\ + \textcolor{lightgray}{All rights reserved.} & \hspace{3cm} \\ + & \hspace{3cm} \\ + & \hspace{3cm} \\ + +\end{tabularx} +\end{adjustwidth} + +\end{titlepage} +\RemoveFromHook{shipout/background} +\AddToHook{shipout/background}{ + \begin{tikzpicture}[remember picture,overlay] + \node[anchor=south west, align=left, inner sep=0] at (current page.south west) { + \includegraphics[width=\paperwidth]{normal-page-footer} + }; + \end{tikzpicture} + \begin{tikzpicture}[remember picture,overlay] + \node[anchor=north east, opacity=0.5, inner sep=35] at (current page.north east) { + \includegraphics[width=4cm]{Canonical-logo-4x} + }; + \end{tikzpicture} + } +''', +} \ No newline at end of file diff --git a/docs/.sphinx/metrics/build_metrics.sh b/docs/.sphinx/metrics/build_metrics.sh new file mode 100755 index 0000000000..bd1ff1cb4c --- /dev/null +++ b/docs/.sphinx/metrics/build_metrics.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# shellcheck disable=all + +links=0 +images=0 + +# count number of links +links=$(find . -type d -path './.sphinx' -prune -o -name '*.html' -exec cat {} + | grep -o " \n" \ + "------------------------------------------------------------- \n" + +.PHONY: full-help woke-install spellcheck-install pa11y-install install run html \ + epub serve clean clean-doc spelling spellcheck linkcheck woke \ + allmetrics pa11y pdf-prep-force pdf-prep pdf Makefile.sp vale bash + +full-help: $(VENVDIR) + @. $(VENV); $(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + @echo "\n\033[1;31mNOTE: This help texts shows unsupported targets!\033[0m" + @echo "Run 'make help' to see supported targets." + +# If requirements are updated, venv should be rebuilt and timestamped. +$(VENVDIR): + python3 -c "import venv" || \ + (echo "You must install python3-venv before you can build the documentation."; exit 1) + @echo "... setting up virtualenv" + python3 -m venv $(VENVDIR) + . $(VENV); pip install $(PIPOPTS) --require-virtualenv \ + --upgrade -r $(SPHINXDIR)/requirements.txt \ + --log $(VENVDIR)/pip_install.log + @test ! -f $(VENVDIR)/pip_list.txt || \ + mv $(VENVDIR)/pip_list.txt $(VENVDIR)/pip_list.txt.bak + @. $(VENV); pip list --local --format=freeze > $(VENVDIR)/pip_list.txt + @touch $(VENVDIR) + +woke-install: + @type woke >/dev/null 2>&1 || \ + { \ + echo "Installing system-wide \"woke\" snap..."; \ + confirm_sudo=$(CONFIRM_SUDO); \ + if [ "$$confirm_sudo" != "y" ] && [ "$$confirm_sudo" != "Y" ]; then \ + read -p "This requires sudo privileges. Proceed? [y/N]: " confirm_sudo; \ + fi; \ + if [ "$$confirm_sudo" = "y" ] || [ "$$confirm_sudo" = "Y" ]; then \ + sudo snap install woke; \ + else \ + echo "Installation cancelled."; \ + fi \ + } + +spellcheck-install: + @type aspell >/dev/null 2>&1 || \ + { \ + echo "Installing system-wide \"aspell\" packages..."; \ + confirm_sudo=$(CONFIRM_SUDO); \ + if [ "$$confirm_sudo" != "y" ] && [ "$$confirm_sudo" != "Y" ]; then \ + read -p "This requires sudo privileges. Proceed? [y/N]: " confirm_sudo; \ + fi; \ + if [ "$$confirm_sudo" = "y" ] || [ "$$confirm_sudo" = "Y" ]; then \ + sudo apt-get install aspell aspell-en; \ + else \ + echo "Installation cancelled."; \ + fi \ + } + +pa11y-install: + @type $(PA11Y) >/dev/null 2>&1 || { \ + echo "Installing \"pa11y\" from npm... \n"; \ + mkdir -p $(SPHINXDIR)/node_modules/ ; \ + npm install --prefix $(SPHINXDIR) pa11y; \ + } + +install: $(VENVDIR) + +run: install + . $(VENV); $(VENVDIR)/bin/sphinx-autobuild -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) + +# Doesn't depend on $(BUILDDIR) to rebuild properly at every run. +html: install + . $(VENV); $(SPHINXBUILD) -W --keep-going -b dirhtml "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS) + +epub: install + . $(VENV); $(SPHINXBUILD) -b epub "$(SOURCEDIR)" "$(BUILDDIR)" -w $(SPHINXDIR)/warnings.txt $(SPHINXOPTS) + +serve: html + cd "$(BUILDDIR)"; python3 -m http.server --bind 127.0.0.1 8000 + +clean: clean-doc + @test ! -e "$(VENVDIR)" -o -d "$(VENVDIR)" -a "$(abspath $(VENVDIR))" != "$(VENVDIR)" + rm -rf $(VENVDIR) + rm -rf $(SPHINXDIR)/node_modules/ + rm -rf $(SPHINXDIR)/styles + rm -rf $(SPHINXDIR)/vale.ini + +clean-doc: + git clean -fx "$(BUILDDIR)" + rm -rf $(SPHINXDIR)/.doctrees + +spellcheck: spellcheck-install + . $(VENV) ; python3 -m pyspelling -c $(SPHINXDIR)/spellingcheck.yaml -j $(shell nproc) + +spelling: html spellcheck + +linkcheck: install + . $(VENV) ; $(SPHINXBUILD) -b linkcheck "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) || { grep --color -F "[broken]" "$(BUILDDIR)/output.txt"; exit 1; } + exit 0 + +woke: woke-install + woke $(ALLFILES) --exit-1-on-failure \ + -c https://raw.githubusercontent.com/canonical/Inclusive-naming/main/config.yml + +pa11y: pa11y-install html + find $(BUILDDIR) -name *.html -print0 | xargs -n 1 -0 $(PA11Y) + +vale: install + @. $(VENV); test -d $(SPHINXDIR)/venv/lib/python*/site-packages/vale || pip install vale + @. $(VENV); test -f $(SPHINXDIR)/vale.ini || python3 $(SPHINXDIR)/get_vale_conf.py + @. $(VENV); find $(SPHINXDIR)/venv/lib/python*/site-packages/vale/vale_bin -size 195c -exec vale --config "$(SPHINXDIR)/vale.ini" $(TARGET) > /dev/null \; + @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt + @cat $(SPHINXDIR)/.wordlist.txt $(SOURCEDIR)/.custom_wordlist.txt >> $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt + @echo "" + @echo "Running Vale against $(TARGET). To change target set TARGET= with make command" + @echo "" + @. $(VENV); vale --config "$(SPHINXDIR)/vale.ini" --glob='*.{md,txt,rst}' $(TARGET) || true + @cat $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt > $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept.txt && rm $(SPHINXDIR)/styles/config/vocabularies/Canonical/accept_backup.txt + +pdf-prep: install + @for packageName in $(REQPDFPACKS); do (dpkg-query -W -f='$${Status}' $$packageName 2>/dev/null | \ + grep -c "ok installed" >/dev/null && echo "Package $$packageName is installed") && continue || \ + (echo "\nPDF generation requires the installation of the following packages: $(REQPDFPACKS)" && \ + echo "" && echo "Run 'sudo make pdf-prep-force' to install these packages" && echo "" && echo \ + "Please be aware these packages will be installed to your system") && exit 1 ; done + +pdf-prep-force: + apt-get update + apt-get upgrade -y + apt-get install --no-install-recommends -y $(REQPDFPACKS) \ + +pdf: pdf-prep + @. $(VENV); sphinx-build -M latexpdf "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) + @rm ./$(BUILDDIR)/latex/front-page-light.pdf || true + @rm ./$(BUILDDIR)/latex/normal-page-footer.pdf || true + @find ./$(BUILDDIR)/latex -name "*.pdf" -exec mv -t ./$(BUILDDIR) {} + + @rm -r $(BUILDDIR)/latex + @echo "\nOutput can be found in ./$(BUILDDIR)\n" + +allmetrics: html + @echo "Recording documentation metrics..." + @echo "Checking for existence of vale..." + . $(VENV) + @. $(VENV); test -d $(SPHINXDIR)/venv/lib/python*/site-packages/vale || pip install vale + @. $(VENV); test -f $(SPHINXDIR)/vale.ini || python3 $(SPHINXDIR)/get_vale_conf.py + @. $(VENV); find $(SPHINXDIR)/venv/lib/python*/site-packages/vale/vale_bin -size 195c -exec vale --config "$(SPHINXDIR)/vale.ini" $(TARGET) > /dev/null \; + @eval '$(METRICSDIR)/source_metrics.sh $(PWD)' + @eval '$(METRICSDIR)/build_metrics.sh $(PWD) $(METRICSDIR)' + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: + . $(VENV); $(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000000..522e6bc7be --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,325 @@ +import datetime +import ast + +# Configuration for the Sphinx documentation builder. +# All configuration specific to your project should be done in this file. +# +# If you're new to Sphinx and don't want any advanced or custom features, +# just go through the items marked 'TODO'. +# +# A complete list of built-in Sphinx configuration values: +# https://www.sphinx-doc.org/en/master/usage/configuration.html +# +# Our starter pack uses the custom Canonical Sphinx extension +# to keep all documentation based on it consistent and on brand: +# https://github.com/canonical/canonical-sphinx + + +####################### +# Project information # +####################### + +# Project name +# +# TODO: Update with the official name of your project or product + +project = "Multipass" +author = "Canonical Ltd." + + +# Sidebar documentation title; best kept reasonably short +# +# TODO: To include a version number, add it here (hardcoded or automated). +# +# TODO: To disable the title, set to an empty string. + +html_title = project + " documentation" + + +# Copyright string; shown at the bottom of the page +# +# Now, the starter pack uses CC-BY-SA as the license +# and the current year as the copyright year. +# +# TODO: If your docs need another license, specify it instead of 'CC-BY-SA'. +# +# TODO: If your documentation is a part of the code repository of your project, +# it inherits the code license instead; specify it instead of 'CC-BY-SA'. +# +# NOTE: For static works, it is common to provide the first publication year. +# Another option is to provide both the first year of publication +# and the current year, especially for docs that frequently change, +# e.g. 2022–2023 (note the en-dash). +# +# A way to check a repo's creation date is to get a classic GitHub token +# with 'repo' permissions; see https://github.com/settings/tokens +# Next, use 'curl' and 'jq' to extract the date from the API's output: +# +# curl -H 'Authorization: token ' \ +# -H 'Accept: application/vnd.github.v3.raw' \ +# https://api.github.com/repos/canonical/ | jq '.created_at' + +copyright = "%s CC-BY-SA, %s" % (datetime.date.today().year, author) + + +# Documentation website URL +# +# TODO: Update with the official URL of your docs or leave empty if unsure. +# +# NOTE: The Open Graph Protocol (OGP) enhances page display in a social graph +# and is used by social media platforms; see https://ogp.me/ + +ogp_site_url = "https://canonical.com/multipass/docs" + + +# Preview name of the documentation website +# +# TODO: To use a different name for the project in previews, update as needed. + +ogp_site_name = project + + +# Preview image URL +# +# TODO: To customise the preview image, update as needed. + +ogp_image = "https://assets.ubuntu.com/v1/253da317-image-document-ubuntudocs.svg" + + +# Product favicon; shown in bookmarks, browser tabs, etc. + +# TODO: To customise the favicon, uncomment and update as needed. + +# html_favicon = '.sphinx/_static/favicon.png' + + +# Dictionary of values to pass into the Sphinx context for all pages: +# https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_context + +html_context = { + # Product page URL; can be different from product docs URL + # + # TODO: Change to your product website URL, + # dropping the 'https://' prefix, e.g. 'ubuntu.com/lxd'. + # + # TODO: If there's no such website, + # remove the {{ product_page }} link from the page header template + # (usually .sphinx/_templates/header.html; also, see README.rst). + "product_page": "documentation.ubuntu.com", + # Product tag image; the orange part of your logo, shown in the page header + # + # TODO: To add a tag image, uncomment and update as needed. + # 'product_tag': '_static/tag.png', + # Your Discourse instance URL + # + # TODO: Change to your Discourse instance URL or leave empty. + # + # NOTE: If set, adding ':discourse: 123' to an .rst file + # will add a link to Discourse topic 123 at the bottom of the page. + "discourse": "https://discourse.ubuntu.com", + # Your Mattermost channel URL + # + # TODO: Change to your Mattermost channel URL or leave empty. + "mattermost": "https://chat.canonical.com/canonical/channels/documentation", + # Your Matrix channel URL + # + # TODO: Change to your Matrix channel URL or leave empty. + "matrix": "https://matrix.to/#/#documentation:ubuntu.com", + # Your documentation GitHub repository URL + # + # TODO: Change to your documentation GitHub repository URL or leave empty. + # + # NOTE: If set, links for viewing the documentation source files + # and creating GitHub issues are added at the bottom of each page. + "github_url": "https://github.com/canonical/multipass", + + # NOTE TO GIULIA: This line was suggested by Shane to enable the feedback button, + # but it doesn't work at the moment. + # 'github_issues': 'enabled', + + # Docs branch in the repo; used in links for viewing the source files + # + # TODO: To customise the branch, uncomment and update as needed. + # 'github_version': 'main', + # Docs location in the repo; used in links for viewing the source files + # + # TODO: To customise the directory, uncomment and update as needed. + "github_folder": "/docs/", + # TODO: To enable or disable the Previous / Next buttons at the bottom of pages + # Valid options: none, prev, next, both + # "sequential_nav": "both", + # TODO: To enable listing contributors on individual pages, set to True + "display_contributors": False, +} + +# Project slug; see https://meta.discourse.org/t/what-is-category-slug/87897 +# +# TODO: If your documentation is hosted on https://docs.ubuntu.com/, +# uncomment and update as needed. + +# slug = '' + + +# Template and asset locations + +html_static_path = [".sphinx/_static"] +templates_path = [".sphinx/_templates"] + + +############# +# Redirects # +############# + +# To set up redirects: https://documatt.gitlab.io/sphinx-reredirects/usage.html +# For example: 'explanation/old-name.html': '../how-to/prettify.html', + +# To set up redirects in the Read the Docs project dashboard: +# https://docs.readthedocs.io/en/stable/guides/redirects.html + +# NOTE: If undefined, set to None, or empty, +# the sphinx_reredirects extension will be disabled. + +redirects = {} + + +########################### +# Link checker exceptions # +########################### + +# A regex list of URLs that are ignored by 'make linkcheck' +# +# TODO: Remove or adjust the ACME entry after you update the contributing guide + +linkcheck_ignore = [ + "http://127.0.0.1:8000", + "https://github.com/canonical/ACME/*" + ] + + +# A regex list of URLs where anchors are ignored by 'make linkcheck' + +linkcheck_anchors_ignore_for_url = [r"https://github\.com/.*"] + + +######################## +# Configuration extras # +######################## + +# Custom MyST syntax extensions; see +# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html +# +# NOTE: By default, the following MyST extensions are enabled: +# substitution, deflist, linkify + +# myst_enable_extensions = set() + + +# Custom Sphinx extensions; see +# https://www.sphinx-doc.org/en/master/usage/extensions/index.html + +# NOTE: The canonical_sphinx extension is required for the starter pack. +# It automatically enables the following extensions: +# - custom-rst-roles +# - myst_parser +# - notfound.extension +# - related-links +# - sphinx_copybutton +# - sphinx_design +# - sphinx_reredirects +# - sphinx_tabs.tabs +# - sphinxcontrib.jquery +# - sphinxext.opengraph +# - terminal-output +# - youtube-links + +extensions = [ + "canonical_sphinx", + "sphinxcontrib.cairosvgconverter", + "sphinx_last_updated_by_git", +] + +# Excludes files or directories from processing + +exclude_patterns = [ + "doc-cheat-sheet*", +] + +# Adds custom CSS files, located under 'html_static_path' + +html_css_files = [ + "css/pdf.css", +] + + +# Adds custom JavaScript files, located under 'html_static_path' + +# html_js_files = [] + + +# Specifies a reST snippet to be appended to each .rst file + +rst_epilog = """ +.. include:: /reuse/links.txt +""" + +# Feedback button at the top; enabled by default +# +# TODO: To disable the button, uncomment this. + +# disable_feedback_button = True + +# NOTE TO GIULIA: This line was suggested by Shane to enable the feedback button, +# but it doesn't work at the moment. +# 'github_issues': 'enabled', + +# Your manpage URL +# +# TODO: To enable manpage links, uncomment and update as needed. +# +# NOTE: If set, adding ':manpage:' to an .rst file +# adds a link to the corresponding man section at the bottom of the page. + +# manpages_url = f'https://manpages.ubuntu.com/manpages/{codename}/en/' + \ +# f'man{section}/{page}.{section}.html' + + +# Specifies a reST snippet to be prepended to each .rst file +# This defines a :center: role that centers table cell content. +# This defines a :h2: role that styles content for use with PDF generation. + +rst_prolog = """ +.. role:: center + :class: align-center +.. role:: h2 + :class: hclass2 +""" + +# Workaround for https://github.com/canonical/canonical-sphinx/issues/34 + +if "discourse_prefix" not in html_context and "discourse" in html_context: + html_context["discourse_prefix"] = html_context["discourse"] + "/t/" + +##################### +# PDF configuration # +##################### + +latex_additional_files = [ + "./.sphinx/fonts/Ubuntu-B.ttf", + "./.sphinx/fonts/Ubuntu-R.ttf", + "./.sphinx/fonts/Ubuntu-RI.ttf", + "./.sphinx/fonts/UbuntuMono-R.ttf", + "./.sphinx/fonts/UbuntuMono-RI.ttf", + "./.sphinx/fonts/UbuntuMono-B.ttf", + "./.sphinx/images/Canonical-logo-4x.png", + "./.sphinx/images/front-page-light.pdf", + "./.sphinx/images/normal-page-footer.pdf", +] + +latex_engine = "xelatex" +latex_show_pagerefs = True +latex_show_urls = "footnote" + +with open(".sphinx/latex_elements_template.txt", "rt") as file: + latex_config = file.read() + +latex_elements = ast.literal_eval(latex_config.replace("$PROJECT", project)) diff --git a/docs/contribute-to-multipass-docs.md b/docs/contribute-to-multipass-docs.md new file mode 100644 index 0000000000..7fce9c6db5 --- /dev/null +++ b/docs/contribute-to-multipass-docs.md @@ -0,0 +1,58 @@ +# Contribute to Multipass docs +Our documentation is a community effort and anyone can contribute. + +**We warmly welcome community contributions, suggestions, fixes and constructive feedback.** + +## Documentation practice + +Multipass documentation is organised according to the [Diátaxis](https://diataxis.fr/) framework and (mostly) follows the [Canonical documentation style guide](https://docs.ubuntu.com/styleguide/en/). + +At Canonical, we have embarked on a comprehensive, long-term project to transform documentation. Our aim is to create and maintain documentation product and practice that will represent a standard of excellence. We want documentation to be the best it possibly can be. + +> See also: [Documentation practice at Canonical](https://canonical.com/documentation) and [Diátaxis, a new foundation for Canonical documentation](https://ubuntu.com/blog/diataxis-a-new-foundation-for-canonical-documentation) + +## How you can contribute + +Multipass documentation is maintained on our Discourse forum. Every documentation page has an equivalent topic on the forum, that can be accessed by clicking the "Help improve this document in the forum" link at the bottom of the page. + +![image|540x103](upload://w2UG2yP4Vqu4VyiaLxq1SE25GI3.png) + +To contribute to the documentation, you can leave a comment on the relevant forum topic, or edit content directly if your *Trust level* allows it. However, if your intervention is bigger than fixing a typo, it’s a good idea to comment on the page to discuss first. + +Either way, your name will be added to the Contributors list at the bottom of the page. + +### Formatting content + +In Discourse, content is formatted using Markdown syntax. You can also use the style toolbar in the Discourse topic editing window to format elements, if you're not familiar with Markdown. + +> See also: [Discourse | Supported formatting in posts (markdown, BBCcode, and HTML ](https://meta.discourse.org/t/supported-formatting-in-posts-markdown-bbcode-and-html/239348) (in particular, the link to [`markdown-it` ](https://markdown-it.github.io/) and [CommonMark Spec ](https://spec.commonmark.org/)) + +A useful trick to view the Markdown source of a Discourse page is replacing `/t//` in the URL with `/raw/`. For example, to view the source of the [Multipass Documentation home](https://multipass.run/docs) topic, instead of the default Discourse URL: + +* `https://discourse.ubuntu.com/t/multipass-documentation/8294` + +try pasting this modified URL in your browser's address bar: + +* `https://discourse.ubuntu.com/raw/8294` + +## Join the Open Documentation Academy + +The [Canonical Open Documentation Academy](https://canonical.com/documentation/open-documentation-academy) (CODA) is a community-oriented initiative led by our Technical Authors to provide help, advice and mentorship on documentation practice in a friendly, welcoming environment. A key aim of this initiative is to help lower the barrier to successful open source software contribution by making documentation into the gateway. + +> See also: [Documentation practice at Canonical](https://canonical.com/documentation). + +If you want to contribute to Multipass documentation, you can also check if there are any outstanding tasks on the [Open Documentation Academy GitHub](https://github.com/canonical/open-documentation-academy/issues?q=is%3Aissue+is%3Aopen+multipass+). This could be a great opportunity to improve your documentation practice, receive guidance and mentorship and publicly contribute to an open-source project, if that's something that interests you. + +Everyone is invited join the Academy's [weekly office hours](https://discourse.ubuntu.com/t/documentation-office-hours/42771), listen in to presentations and participate in discussions. Live sessions are also recorded and made available on the[ Ubuntu on Air YouTube channel](https://www.youtube.com/@UbuntuOnAir), in the[ Documentation Academy playlist](https://www.youtube.com/watch?v=GT03aSdabJE&list=PL-qBHd6_LXWYefHij0dJ7c9X-Q9QfFFFa&pp=iAQB). + + +## Feedback and issues + +You can leave feedback on our documentation using the [Multipass documentation feedback form](https://docs.google.com/forms/d/e/1FAIpQLSd0XZDU9sbOCiljceh3rO_rkp6vazy2ZsIWgx4gsvl_Sec4Ig/viewform) linked at the top of every page. If you have a request or would like to report a problem with the documentation, you may also [open an issue on GitHub](https://github.com/canonical/multipass/issues/new/choose). + +You can also find the team in the [Matrix Multipass room](https://app.element.io/#/room/#Multipass:matrix.org). + +--- + +Don’t hesitate to contribute, we value your input and suggestions! + diff --git a/docs/explanation/about-performance.md b/docs/explanation/about-performance.md new file mode 100644 index 0000000000..c5f47a3aad --- /dev/null +++ b/docs/explanation/about-performance.md @@ -0,0 +1,44 @@ +# About performance +When considering performance with Multipass, there are two aspects that need to be accounted for: + +* the [Multipass instance](/explanation/instance) +* the [host machine](/explanation/host) + +There are many factors that can affect the performance of the instance and the host. To ensure the best performance of both areas, careful consideration should be given. + +## Host system + +Here you'll find some considerations and recommendations on allocating host system resources. + +### CPUs/cores/threads + +When provisioning a Multipass instance, you should take into account the host's CPU speed and the number of cores and threads. You should also consider the number of instances that will be running simultaneously. + +The number of cores allocated to an instance and the number of running instances will greatly impact processes running on the host machine itself. As general guidance, you should reserve at least two threads, that will not be allocated to running instances. + +Of course, there may be other factors in different host machines that can greatly affect how well they perform when running Multipass instances. + +### Memory usage + +The amount of memory allocated to instances can also greatly impact the host system. + +You should not overallocate memory for running Multipass instances, as this can cause the host to appear slower than normal or become unresponsive. + +We recommend that you reserve at least 4GB of memory for the host, but this also depends on the workload of the host itself, so more memory may be needed. + +## Multipass instances + +Here you'll find some considerations and recommendations on allocating resources to your instances. + +### CPUs + +The number of CPUs allocated to a Multipass instance has a direct impact on the performance of the instance itself. Generally, the more CPUs allocated, the more potential for better performance in the instance. This depends heavily on the workload intended for instance. + +### Memory + +As with cores, the amount of memory allocated to a Multipass instance will also have a direct on its performance. This is also dependent on the intended workload of instances. Naturally, more memory intensive workloads provide much larger gains in performance if more memory is allocated to the instance. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/about-security.md b/docs/explanation/about-security.md new file mode 100644 index 0000000000..04f19e1acb --- /dev/null +++ b/docs/explanation/about-security.md @@ -0,0 +1,23 @@ +# About security +> See also: [Authentication](/explanation/authentication), [How to authenticate clients with the Multipass service](/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service), [`authenticate`](/reference/command-line-interface/authenticate), [`local.passphrase`](/reference/settings/local-passphrase) + +```{caution} +**WARNING** + +Multipass is primarily intended for development, testing, and local environments. It is not intended for production use. Review the security considerations in this page carefully before deploying your Multipass VMs. +``` + +Multipass runs a daemon that is accessed locally via a Unix socket on Linux and macOS, and over a TLS socket on Windows. Anyone with access to the socket can fully control Multipass, which includes mounting host file systems or to tweaking the security features for all instances. + +Therefore, make sure to restrict access to the daemon to trusted users. + +## Local access to the Multipass daemon + +The Multipass daemon runs as root and provides a Unix socket for local communication. Access control for Multipass is initially based on group membership and later by the client's TLS certificate when accepted by providing a set passphrase. + +The first client to connect that is a member of the `sudo` group (or `wheel`/`adm`, depending on the OS) will automatically have its TLS certificate imported into the Multipass daemon and will be authenticated to connect. After this, any other client connecting will need to [`authenticate`](/reference/command-line-interface/authenticate) first by providing a [passphrase](/reference/settings/local-passphrase) set by the administrator. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/alias.md b/docs/explanation/alias.md new file mode 100644 index 0000000000..70ac940a8e --- /dev/null +++ b/docs/explanation/alias.md @@ -0,0 +1,9 @@ +# Alias +> See also: [`alias`](/reference/command-line-interface/alias), [How to use command aliases](/how-to-guides/manage-instances/use-instance-command-aliases). + +In Multipass, an **alias** is a shortcut for a command that runs inside a given instance. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/authentication.md b/docs/explanation/authentication.md new file mode 100644 index 0000000000..46b7cd163c --- /dev/null +++ b/docs/explanation/authentication.md @@ -0,0 +1,31 @@ +# Authentication +> See also: [How to authenticate clients with the Multipass service](/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service) + +Before executing any commands, Multipass requires clients to authenticate with the service. Multipass employs an authentication process based on x509 certificates signed by elliptic curve (EC) keys, powered by OpenSSL, to authenticate clients. When a client connects, Multipass verifies the client's certificate, ensuring only authenticated clients can communicate with the service. + +[tabs] + +[tab version="Linux"] +Linux and macOS hosts currently use a Unix domain socket for client and daemon communication. Upon first use, this socket only allows a client to connect via a user belonging to the group that owns the socket. For example, this group could be `sudo`, `admin`, or `wheel` and the user needs to belong to this group or else permission will be denied when connecting. + +After the first client connects with a user belonging to the socket's admin group, the client's OpenSSL certificate will be accepted by the daemon and the socket will be then be open for all users to connect. Any other user trying to connect to the Multipass service will need to authenticate with the service using the previously set [`local.passphrase`](/reference/settings/local-passphrase). +[/tab] + +[tab version="macOS"] +Linux and macOS hosts currently use a Unix domain socket for client and daemon communication. Upon first use, this socket only allows a client to connect via a user belonging to the group that owns the socket. For example, this group could be `sudo`, `admin`, or `wheel` and the user needs to belong to this group or else permission will be denied when connecting. + +After the first client connects with a user belonging to the socket's admin group, the client's OpenSSL certificate will be accepted by the daemon and the socket will be then be open for all users to connect. Any other user trying to connect to the Multipass service will need to authenticate with the service using the previously set [`local.passphrase`](/reference/settings/local-passphrase). +[/tab] + +[tab version="Windows"] +The Windows host uses a TCP socket listening on port 50051 for client connections. This socket is open for all to use since there is no concept of file ownership for TCP sockets. This is not very secure in that any Multipass client can connect to the service and issue any commands. + +To close this gap, the client will now need to be authenticated with the Multipass service. To ease the burden of having to authenticate the client, the user who installs the updated version of Multipass will automatically have their clients authenticated with the service. Any other users connecting to the service will have to use authenticate using the previously set [`local.passphrase`](/reference/settings/local-passphrase). +[/tab] + +[/tabs] + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/blueprint.md b/docs/explanation/blueprint.md new file mode 100644 index 0000000000..43850f7736 --- /dev/null +++ b/docs/explanation/blueprint.md @@ -0,0 +1,44 @@ +# Blueprint +> See also: [How to use a blueprint](/how-to-guides/manage-instances/use-a-blueprint) + +In Multipass, a **blueprint** is a recipe to create a customised Multipass [instance](/explanation/instance). + +Blueprints consist of a base image, cloud-init initialisation, and a set of parameters describing the instance itself, e.g. minimum memory, CPUs or disk. + +Blueprints are defined from a YAML file with the following schema: + +``` +# v1/.yaml + +description: # * a short description of the blueprint ("tagline") +version: # * a version string + +runs-on: # a list of architectures this blueprint can run on +- arm64 # see https://doc.qt.io/qt-5/qsysinfo.html#currentCpuArchitecture +- x86_64 # for a list of valid values + +instances: + : # * equal to the blueprint name + image: # a valid image alias, see `multipass find` for available values + limits: + min-cpu: # the minimum number of CPUs this blueprint can work with + min-mem: # the minimum amount of memory (can use G/K/M/B suffixes) + min-disk: # and the minimum disk size (as above) + timeout: # maximum time for the instance to launch, and separately for cloud-init to complete + cloud-init: + vendor-data: | # cloud-init vendor data + + +health-check: | # a health-check shell script ran by integration tests + + +``` + +Blueprints currently integrated into Multipass can be found with the [`multipass find`](/reference/command-line-interface/find) command. + +For more information on creating a blueprint for inclusion into Multipass, please refer to the [GitHub project](https://github.com/canonical/multipass-blueprints). + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/driver.md b/docs/explanation/driver.md new file mode 100644 index 0000000000..cf56c356d9 --- /dev/null +++ b/docs/explanation/driver.md @@ -0,0 +1,71 @@ +# Driver +> See also: [How to set up the driver](/how-to-guides/customise-multipass/set-up-the-driver), [`local.driver`](/reference/settings/local-driver), [Instance](/explanation/instance), [Platform](/explanation/platform) + +A **driver** is the technology through which Multipass emulates a running machine. It corresponds to a hypervisor or intermediary technology to run virtual machines. The driver is sometimes also referred to as "backend". + +Multipass relies on a driver to operate. It supports multiple drivers, but it runs with a single driver at a time. There is a [Multipass setting](/reference/settings/settings) to select the driver: [`local.driver`](/reference/settings/local-driver). + +On some platforms, it is possible to select a driver during installation. Until it is manually set, a platform-appropriate default driver is used. + +## Supported drivers + +Different sets of drivers are available on different platforms: + +- On Linux, Multipass can be configured to use QEMU, LXD, and libvirt. +- On macOS, the options are QEMU and VirtualBox. As of Multipass version 1.13, Hyperkit is no longer available. +- On Windows, Multipass uses Hyper-V (only available on Windows Pro) or VirtualBox. + +## Default drivers + +When Multipass is installed, the following drivers are selected by default: + +- On Linux, the default driver depends on the host's architecture: + + QEMU on amd64 + + LXD on other platforms. +- On macOS, QEMU is used. +- On Windows, the default driver depends on the OS version: + + Hyper-V on Windows Pro + + VirtualBox on Windows Home + +## Instance scopes + +In general, Multipass instances are tied to a single driver, with the [exceptions](#exceptions) listed below. The set of instances that were launched with one driver are available only while that driver is in use. + +When a new driver is selected, Multipass switches to a separate instance scope. There, the set of existing instances is empty to begin with. Users can launch instances with the same name in different drivers and changes to instances with one driver have no effect on the instances of another. + +Nonetheless, instances are preserved across drivers. After switching back to a previously-used driver, Multipass restores the corresponding instance scope. It attempts to restore the state instances were in just before the switch and users can interact with them just as before. + +### Exceptions + +There are two exceptions to the above: + + - On Linux, QEMU and libvirt share the same driver scope. + - On macOS, stopped Hyperkit instances are automatically migrated to QEMU by Multipass's version 1.12 or later (see: [How to migrate from Hyperkit to QEMU on macOS](/how-to-guides/customise-multipass/migrate-from-hyperkit-to-qemu-on-macos)). + +## Feature disparities + +While we strive to offer a uniform interface across the board, not all features are available on all backends and there are some behaviour differences: + +| Feature | Only supported on... | Notes | +|--- | --- | --- | +| **Native mounts** |
  • Hyper-V
  • LXD
  • QEMU
| This affects the `--type` option in the [`mount`](/reference/command-line-interface/mount) command). | +| **Extra networks** |
  • Hyper-V
  • LXD
  • QEMU
  • VirtualBox
| This affects the [`networks`](/reference/command-line-interface/networks) command, as well as the `--network` and `--bridged` options in [`launch`](/reference/command-line-interface/launch). | +| **Snapshots** |
  • Hyper-V
  • QEMU
  • VirtualBox
| | +| **Clone** |
  • Hyper-V
  • QEMU
  • VirtualBox
| This affects the [`clone`](/reference/command-line-interface/clone) command.| +| **VM suspension** |
  • Hyper-V
  • libvirt
  • QEMU
  • VirtualBox
| This affects the [`suspend`](/reference/command-line-interface/suspend) command. | + + + +[note type="information"] +There are also feature disparities depending on the host platform. See [Platform](/explanation/platform) for more details. +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/host.md b/docs/explanation/host.md new file mode 100644 index 0000000000..6a3231fbb9 --- /dev/null +++ b/docs/explanation/host.md @@ -0,0 +1,7 @@ +# Host +In Multipass, **host** refers the actual physical machine on which Multipass is running. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/id-mapping.md b/docs/explanation/id-mapping.md new file mode 100644 index 0000000000..17ff790795 --- /dev/null +++ b/docs/explanation/id-mapping.md @@ -0,0 +1,33 @@ +# ID mapping +> See also: [`mount`](/reference/command-line-interface/mount), [Mount](/explanation/mount), [How to share data with an instance](/how-to-guides/manage-instances/share-data-with-an-instance) + +**ID mapping** refers to the process of aligning user or group IDs between the host system and an instance when mounting directories. This alignment ensures that the files mounted from the host to the instance retain consistent ownership and permission attributes. + +Since ID mappings take effect from host to instance, as well as in the opposite direction, they must be defined as a one-to-one relationship, meaning that each user or group ID on the host system should be mapped directly to a single user or group ID within the virtual machine, and vice versa. + +For example, the user ID `501` can be mapped to the user ID `1000` in the "foo" instance: + +``` +multipass mount ~/Documents foo:Documents -u 501:1000 +``` + +On the other hand, it is not possible to map this same user to a second user ID within the instance, as Multipass would be unable to determine which user ID to assign on the instance to a file with a user ID of `501` on the host system. The following command defines an invalid mount, since more than one ID on the host is mapped to the same ID in the instance: + +`multipass mount ~/Documents foo:Documents -u 501:1000 -u 502:1000` + +Instead, a valid mount that maps two different user IDs could be defined as follows: + +``` +multipass mount ~/Documents foo:Documents -u 501:1000 -u 502:1001 +``` + +The same logic also applies when trying to map a single user or group ID in an instance to two different IDs on the host. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @sharder996 , @gzanchi + diff --git a/docs/explanation/image.md b/docs/explanation/image.md new file mode 100644 index 0000000000..80c5a016f4 --- /dev/null +++ b/docs/explanation/image.md @@ -0,0 +1,21 @@ +# Image +> See also: [`find`](/reference/command-line-interface/find), [`launch`](/reference/command-line-interface/launch) + +Multipass uses **images** (short for [disk images](https://en.wikipedia.org/wiki/Disk_image) or [system images](https://en.wikipedia.org/wiki/System_image)) tuned for cloud usage to spin up Ubuntu VMs. + +You can use `multipass find` to view a list of the available images. These images are obtained from different sources, such as: +* Ubuntu Cloud Images: https://cloud-images.ubuntu.com/ +* Ubuntu CD Images: https://cdimages.ubuntu.com/ + +and more. + +You can also launch images from a file or URL, as long as they provide the tools required to deploy a cloud. The key requirements are: +* cloud-init +* SSH + +For more information on the system requirements for a particular image, refer to official documentation (for example: [Ubuntu Core system requirements](https://ubuntu.com/core/docs/system-requirements)). + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/index.md b/docs/explanation/index.md new file mode 100644 index 0000000000..8ffa85bf28 --- /dev/null +++ b/docs/explanation/index.md @@ -0,0 +1,32 @@ +# Explanation +The following explanations provide context and clarification on key-topics related to the use and configuration of Multipass. + +- [About security](/explanation/about-security) +- [About performance](/explanation/about-performance) +- [Alias](/explanation/alias) +- [Authentication](/explanation/authentication) +- [Blueprint](/explanation/blueprint) +- [Driver](/explanation/driver) +- [Host](/explanation/host) +- [ID mapping](/explanation/id-mapping) +- [Image](/explanation/image) +- [Instance](/explanation/instance) +- [Mount](/explanation/mount) +- [Multipass `exec` and shells](/explanation/multipass-exec-and-shells) +- [Platform](/explanation/platform) +- [Service](/explanation/service) +- [Snapshot](/explanation/snapshot) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + + +```{toctree} +:hidden: +:titlesonly: +:maxdepth: 2 +:glob: + +* +*/index diff --git a/docs/explanation/instance.md b/docs/explanation/instance.md new file mode 100644 index 0000000000..db9bff2fe5 --- /dev/null +++ b/docs/explanation/instance.md @@ -0,0 +1,29 @@ +# Instance +> See also: [How to manage instances](/how-to-guides/manage-instances/manage-instances), [Instance states](/reference/instance-states), [Mount](/explanation/mount) + +An **instance** is a virtual machine created and managed by Multipass. + +> For more information on the naming convention, see [Instance name format](/reference/instance-name-format). + +## Primary instance + +The Multipass [Command-Line Interface](/reference/command-line-interface/command-line-interface) (CLI) provides a few shortcuts using a special instance, called *primary* instance. By default, this is the instance named `primary`. + +When invoked without positional arguments, state transition commands — [`start`](/reference/command-line-interface/start), [`restart`](/reference/command-line-interface/restart), [`stop`](/reference/command-line-interface/stop), and [`suspend`](/reference/command-line-interface/suspend) — operate on this special instance. So does the [`shell`](/reference/command-line-interface/shell) command. Furthermore, `start` and `shell` create the primary instance if it does not yet exist. + +When creating the primary instance, the Multipass CLI client automatically mounts the user's home directory into it. As with any other mount, it can be unmounted with `multipass umount`. For instance, the command `multipass umount primary` will unmount all mounts made by Multipass inside the `primary` instance, including the auto-mounted `Home`. + +[note type="information"] +On Windows, mounts are disabled by default for security reasons. For more details, see [Mount - Security considerations](/t/28470#security-considerations). +``` + +In all other respects, the primary instance is the same as any other instance. Its properties are the same as if it had been launched manually with `multipass launch --name primary`. + +### Selecting the primary instance + +The name of the instance that the Multipass CLI treats as primary can be modified with the setting [`client.primary-name`](/reference/settings/client-primary-name). This setting determines the name of the instance that Multipass creates and operates as primary, providing a mechanism to turn any existing instance into the primary instance, as well as disabling the primary feature. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/mount.md b/docs/explanation/mount.md new file mode 100644 index 0000000000..52b2b88925 --- /dev/null +++ b/docs/explanation/mount.md @@ -0,0 +1,60 @@ +# Mount +> See also: [`mount`](/reference/command-line-interface/mount), [How to share data with an instance](/how-to-guides/manage-instances/share-data-with-an-instance) + +In Multipass, a **mount** is a directory mapping from the host to an [instance](/explanation/instance), making its contents, and changes therein, available on both ends. Make sure to review the [security considerations](#security-considerations) below. + +In Multipass, there are two types of mounts: classic (default) and native. +* [Classic mounts](#classic-mounts) use technology built into Multipass and thus allow for higher compatibility, while slightly reduced performance. +* [Native mounts](#native-mounts), on the other hand, use hypervisor or platform-specific mounts to offer better performance, but limited compatibility. + +## Classic mounts + +Classic mounts use SSHFS (SSH File System) to achieve file/directory sharing. This option is available across all our backends. + +SSHFS is based on SSH, which pays a performance penalty to achieve secure communication. + +## Native mounts + +Native mounts use driver-dependent technologies to achieve the high performance. They are only available in the following cases: + +- On **Hyper-V**, where they are implemented with [SMB/CIFS](https://learn.microsoft.com/en-us/windows/win32/fileio/microsoft-smb-protocol-and-cifs-protocol-overview). +- On **QEMU**, where they are implemented with [9P](https://en.wikipedia.org/wiki/9P_(protocol)). +- On **LXD**, using that backend's own mounts, which also rely on [9P](https://en.wikipedia.org/wiki/9P_(protocol)). + +> See also: [Driver (backend) - Feature disparities](/t/28410#feature-disparities) + +## Security considerations + +[tabs] + +[tab version="Linux"] +Because mounts are performed as `root` -- unless installed via snap, see below -- they allow write access to the whole host operating system. But since only privileged users (members of `sudo`, `wheel`, `admin` groups) can use Multipass, this isn't a concern on Linux. + +If Multipass is installed via snap package, [snap confinement](https://snapcraft.io/docs/snap-confinement) prevents mounts outside of the `/home` directory (and to hidden files/folders in the `/home` directory) and possibly, removable media (depending on the connected interfaces). Still, a user (A) with access to Multipass could access mounts that a different user (B) established to B's home directory (that is, outside of A's home). +[/tab] + +[tab version="macOS"] +Because mounts are performed as `root`, they allow write access to the whole host operating system. But since only privileged users (members of `sudo`, `wheel`, `admin` groups) can use Multipass, this isn't a concern on macOS. +[/tab] + +[tab version="Windows"] +Because mounts are performed as privileged users (`SYSTEM` on Windows), they allow write access to the whole host operating system. + +For historical reasons, mounts are disabled by default on Windows, even though in the current version of Multipass users need to authenticate with the daemon before it will service their requests. See [`local.privileged-mounts`](/reference/settings/local-privileged-mounts) for information on how to enable them if needed. + + + +[/tab] + +[/tabs] + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @tmihoc, @georgeliaojia, @ricab, @sharder996, @davidekete, @gzanchi + diff --git a/docs/explanation/multipass-exec-and-shells.md b/docs/explanation/multipass-exec-and-shells.md new file mode 100644 index 0000000000..f2d785156d --- /dev/null +++ b/docs/explanation/multipass-exec-and-shells.md @@ -0,0 +1,132 @@ +# Multipass `exec` and shells +> See also: [`exec` command](/reference/command-line-interface/exec) + +## How `exec` parses commands + +When you call `multipass exec` from a shell, the command is first parsed by the shell you are in. The result of that parsing is what the multipass client sees in its argument list (`argv`). + +For example, when `multipass exec primary -- ls ~` is entered on a Linux shell, the tilde is translated to the calling user's local home directory before the command is passed to Multipass. But this is not the case on a Windows PowerShell, because “~” does not have the same meaning there. + +### Quoting + +Quoting also depends on the calling shell. On most Linux and macOS shells, single quotes delimit a string that the shell passes verbatim to the program. + +The Windows powershell doesn't treat single quotes this way. A program called with `'abc def'` there would get two arguments: `'abc` and `def'`. Double quotes can be used instead: `"abc def"`, but the string they delimit is subject to shell expansion. For example: + +```plain +set USER=me +multipass exec -n rich-zorilla -- bash -c "echo %USER%" +``` + +The output will be: `me`. + +With Multipass, this is seldom a problem, as expansions use a different syntax on Linux: + +```plain +multipass exec -n rich-zorilla -- bash -c "echo $USER" +``` + +The output in this case is: `ubuntu`. + +## How SSH parses commands + +Multipass executes the command after `--` in the given instance as if there was no further shell in the middle (this is a simplification, as the reality is a little more complicated). + +This is slightly different from what one would get with SSH. Consider the following command in a `bash` shell: + +```plain +multipass exec mp-builder -- python3 -c 'import sys; print(sys.argv)' foo bar +``` + +whose output is: `['-c', 'foo', 'bar']`. + +When using SSH, the entire command would need to be enclosed within quotes: + +```plain +ssh -i /var/root/Library/Application\ Support/multipassd/ssh-keys/id_rsa ubuntu@192.168.66.34 python -c 'import sys; print(sys.argv)' foo bar +``` + +Sample output: + +```plain +bash: -c: line 1: syntax error near unexpected token `sys.argv' +bash: -c: line 1: `python -c import sys; print(sys.argv) foo bar' +``` + +## Using a shell to parse commands + +To overcome the above problem with `multipass exec`, one can still have another shell parse the command in the instance with `multipass exec`, it just needs to be called explicitly. For example: + +```plain +multipass exec calm-woodcock -- sh -c 'ls -a ~' +``` + +Sample output: + +```plain +. .. .bash_logout .bashrc .cache .profile .ssh +``` + +Similarly, on the Windows Command Prompt: + +```plain +multipass exec calm-woodcock -- sh -c "ls -a ~" +``` + +Provided we use the appropriate quoting for the calling shell, this behaves the same regardless of the host platform. Without `sh -c`, it also fails on all platforms (although possibly in different ways, depending on whether or not the nested command is quoted). The inner-shell trick provides a more consistent cross-platform experience. + +## Input/output redirection + +The `multipass exec` command can be used together with piping to redirect input/output between commands run on the host and on the instance. For example, this writes the contents of the current directory on the host to a file called `save` in the instance `rich-zorilla`: + +```plain +ls -la | multipass exec -n rich-zorilla -- bash -c "cat > save" +``` + +Conversely, this saves the contents of the home directory inside `rich-zorilla` to a file on the host: + +```plain +multipass exec -n rich-zorilla -- bash -c "ls -la" | cat > save +``` + +## Other shell tricks + +Other shell features can be combined with `multipass exec` for different effects. Here is an example using bash's here-strings: + +```plain +multipass exec -n primary -- bash << EOF +> hostname +> whoami +> EOF +``` + +Sample output: + +```plain +primary +ubuntu +``` + +And another using command substitution: + +```plain +ping $(multipass exec rich-zorilla -- hostname -I) +``` + +Sample output: + +```plain +PING 10.239.73.39 (10.239.73.39) 56(84) bytes of data. +64 bytes from 10.239.73.39: icmp_seq=1 ttl=64 time=0.371 ms +64 bytes from 10.239.73.39: icmp_seq=2 ttl=64 time=0.304 ms +64 bytes from 10.239.73.39: icmp_seq=3 ttl=64 time=0.439 ms +^C +--- 10.239.73.39 ping statistics --- +3 packets transmitted, 3 received, 0% packet loss, time 2054ms +rtt min/avg/max/mdev = 0.304/0.371/0.439/0.055 ms +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/platform.md b/docs/explanation/platform.md new file mode 100644 index 0000000000..11bd1dcad9 --- /dev/null +++ b/docs/explanation/platform.md @@ -0,0 +1,32 @@ +# Platform +> See also: [How to install Multipass](/how-to-guides/install-multipass), [Host](/explanation/host), [Driver](/explanation/driver) + +In Multipass, **platform** refers to the host computer's operating system. This can be Windows, macOS, or Linux. + +## Feature disparities + +While we strive to offer a uniform interface across the board, not all features are available on all platforms and there are some behaviour differences: + +| Feature | Only supported on... | Notes | +|--- | --- | --- | +| **Windows terminal integration** |
  • Windows
| This affects the setting [`client.apps.windows-terminal.profiles`](/reference/settings/client-apps-windows-terminal-profiles) | +| **File and URL launches** |
  • Linux
| This affects the [`launch`](/reference/command-line-interface/launch) command. | +| **Mounts** |
  • Linux
  • macOS
  • Windows (disabled by default)
| On Windows, mounts can be enabled with the setting [`local.privileged-mounts`](/reference/settings/local-privileged-mounts).
This affects the [`mount`](/reference/command-line-interface/mount), [`umount`](/reference/command-line-interface/umount), and [`launch`](/reference/command-line-interface/launch) commands.| +| **Extra networks (QEMU)** |
  • Linux
  • macOS
| When using the QEMU driver, extra networks are only supported on macOS.
This affects the [`networks`](/reference/command-line-interface/networks) command, as well as `--network` and `--bridged` options in [`launch`](/reference/command-line-interface/launch). | +| **Global IPv6 (QEMU)** |
  • Linux
  • macOS
| When using the QEMU driver, global IPv6 addresses are only available on macOS. | +| **Drivers** |
  • Linux
  • macOS
  • Windows
| Different drivers are available on different platforms.
This affects the [`local.driver`](/reference/settings/local-driver) setting.
See [Driver - Feature disparities](/t/28410#feature-disparities) for further behaviour differences depending on the selected driver. | +| **Bridging Wi-Fi networks** |
  • macOS
| Wi-Fi networks are not shown in the output of the [`networks`](/t/multipass-networks-command/19542) command on Linux and Windows. | + + + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/service.md b/docs/explanation/service.md new file mode 100644 index 0000000000..6af724b077 --- /dev/null +++ b/docs/explanation/service.md @@ -0,0 +1,11 @@ +# Service +> See also: [Command-line interface](/reference/command-line-interface/command-line-interface), [GUI client](/reference/gui-client), [Instance](/explanation/instance), [Use Multipass remotely](/) + +In Multipass, the **service** refers to the Multipass server that clients connect to and controls and manages Multipass instances. This can also be referred to as the 'daemon'. Multipass daemon (`multipassd)` runs in the background and it processes the requests from the Multipass [command-line interface](/reference/command-line-interface/command-line-interface), [GUI client](/reference/gui-client), daemon is also in charge of the lifecycle of the [Instances](/explanation/instance). The separation between the client (CLI or GUI) and daemon is a popular architecture because of his advantage, flexibility. For instance, the daemon process can be on a different machine from the client, see [Use Multipass remotely](/) for more details. + +The automatic start of the daemon process is triggered right after the Multipass installation. After that, it is also set up to start automatically at system boot. This setup ensures that the Multipass client can immediately interact with the instances without the need to launch the daemon manually, and restores any persistent instances of Multipass after a system restart. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/explanation/snapshot.md b/docs/explanation/snapshot.md new file mode 100644 index 0000000000..d8f70740e1 --- /dev/null +++ b/docs/explanation/snapshot.md @@ -0,0 +1,27 @@ +# Snapshot +A snapshot is an conceptual image of an instance at some point in time, that can be used to restore the instance to what it was at that instant. + +To achieve this, a snapshot records all mutable properties of an instance, that is, all the properties that can change through interaction with Multipass. These include disk contents and size, number of CPUs, amount of memory, and mounts. On the other hand, aliases are not considered part of the instance and are not recorded. + +## Usage + +You can take a snapshot of an instance with the [`snapshot`](/reference/command-line-interface/snapshot) command, and restore it with the [`restore`](/reference/command-line-interface/restore) command. Taking and restoring a snapshot requires the instance to be stopped. + +You can view a list of the available snapshots with `multipass list --snapshots` and the details of a particular snapshot with `multipass info .`. To delete a snapshot, use the [`multipass delete`](/reference/command-line-interface/delete) command. + +> See also: [`list`](/reference/command-line-interface/list), [`info`](/reference/command-line-interface/info) + +## Parents + +An instance's disk contents are recorded by snapshots in layers: each new snapshot records changes with respect to its parent snapshot. A snapshot's parent is the snapshot that was last taken or restored when the new snapshot is taken. Parent and children snapshots of a deleted snapshot retain a consistent record of the instance. Multipass provides information of snapshots' parent/child relations to help identify their role or contents. + +```{caution} +**Caveats:** +- Long chains of snapshots have a detrimental effect on performance. Since they rely on layers of disk diffs, the more snapshots there are in a sequence, the more hops are necessary to read data that is recorded by the most ancient layers. +- While snapshots are useful to save and recover instance states, their utility as safe backups is limited. Since they are stored in the same medium as the original images, they are as likely to be affected by disk failures. +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service.md b/docs/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service.md new file mode 100644 index 0000000000..8fd4b20cca --- /dev/null +++ b/docs/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service.md @@ -0,0 +1,112 @@ +# Authenticate clients with the Multipass service +> See also: [`authenticate`](/reference/command-line-interface/authenticate), [local.passphrase](/reference/settings/local-passphrase), [Service](/explanation/service) + +Multipass requires clients to be authenticated with the service before allowing commands to complete. + +## Setting the passphrase + +The administrator needs to set a passphrase for clients to authenticate with the Multipass service. The client setting the passphrase will need to already be authenticated. + +There are two ways to proceed: + +* Set the passphrase with an echoless interactive entry, where the passphrase is hidden from view: + + ```plain + multipass set local.passphrase + ``` + + The system will then prompt you to enter a passphrase: + + ```plain + Please enter passphrase: + Please re-enter passphrase: + ``` + +* Set the passphrase in the command line, where the passphrase is visible: + + ```plain + multipass set local.passphrase=foo + ``` + +## Authenticating the client + +A client that is not authorized to connect to the Multipass service will fail when running `multipass` commands. An error will be displayed when this happens. + +For example, if you try running the `multipass list` command: + +```plain +list failed: The client is not authenticated with the Multipass service. +Please use 'multipass authenticate' before proceeding. +``` + +At this time, the client will need to provide the previously set passphrase. This can be accomplished in two ways: + +* Authenticate with an echoless interactive entry, where the passphrase is hidden from view: + + ```plain + multipass authenticate + ``` + + The system will prompt you to enter the passphrase: + + ```plain + Please enter passphrase: + ``` + +* Authenticate in the command line, where the passphrase is visible: + + ```plain + multipass authenticate foo + ``` + +## Troubleshooting + +Here you can find solutions and workarounds for common issues that may arise. + +### The client cannot be authorized and the passphrase cannot be set + +It is possible that another client that is privileged to connect to the Multipass socket will connect first and make it seemingly impossible to set the `local.passphrase` and also `authorize` the client with the service. + +If this is the case, you will see something like the following when you run: + +* `multipass list` + + ```plain + list failed: The client is not authenticated with the Multipass service. + Please use 'multipass authenticate' before proceeding. + ``` + +* `multipass authenticate` + + ```plain + Please enter passphrase: + authenticate failed: Passphrase is not set. Please `multipass set + local.passphrase` with a trusted client. + ``` + +* `multipass set local.passphrase` + + ```plain + Please enter passphrase: + Please re-enter passphrase: + set failed: The client is not authenticated with the Multipass service. + Please use 'multipass authenticate' before proceeding. + ``` + +This may not even work when using `sudo`. + +The following workaround should help get out of this situation: + +```plain +cat ~/snap/multipass/current/data/multipass-client-certificate/multipass_cert.pem | sudo tee -a /var/snap/multipass/common/data/multipassd/authenticated-certs/multipass_client_certs.pem > /dev/null +snap restart multipass +``` + +You may need `sudo` with this last command: `sudo snap restart multipass`. + +At this point, your client should be authenticated with the Multipass service. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/customise-multipass/build-multipass-images-with-packer.md b/docs/how-to-guides/customise-multipass/build-multipass-images-with-packer.md new file mode 100644 index 0000000000..d0c12fc246 --- /dev/null +++ b/docs/how-to-guides/customise-multipass/build-multipass-images-with-packer.md @@ -0,0 +1,64 @@ +# Build Multipass images with Packer +[note type="information"] +Custom images are only supported on Linux. +``` + +[Packer](http://packer.io/) is a utility that lets you (re)build images to run in a variety of environments. Multipass can run those images too, provided some requirements are met (namely, the image has to boot on the hypervisor in use, and [cloud-init](https://cloudinit.readthedocs.io/en/latest/) needs to be available). + +## Setting up the build directory + +The easiest way is to start from an existing [Ubuntu Cloud Image](http://cloud-images.ubuntu.com/), and the base project setup follows (you can click on the filenames to see their contents, `meta-data` is empty on purpose): + +``` +├── cloud-data +│ ├── meta-data +│ └── user-data +└── template.json + +1 directory, 3 files +``` + +To specify a different image or image type, modify the `iso_checksum` and `iso_url` fields within `template.json` + +## Building the image + +You will need to install QEMU and Packer (e.g. `sudo apt install qemu packer`), and from there you can run the following commands: + +```plain +packer build template.json +multipass launch file://$PWD/output-qemu/packer-qemu --disk 5G +``` + +Now, shell into the new instance that was created, for example: + +```plain +multipass shell tolerant-hammerhead +``` + +## Customizing the image + +Now the above works for you, delete the test instance with `multipass delete --purge tolerant-hammerhead` and edit the following section in the `template.json` file: + +```json + { + "type": "shell", + "inline": ["echo Your steps go here."] + }, +``` + +Anything you do here will be reflected in the resulting image. You can install packages, configure services, anything you can do on a running system. You'll need `sudo` (passwordless) for anything requiring admin privileges, or you could add this to the above provisioner to run the whole script privileged: + +```json + "execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'", +``` + +## Next steps + +Go to [Packer's documentation](https://developer.hashicorp.com/packer/docs) to learn about the QEMU builder, other provisioners and their configurations as well as everything else that might come in handy. Alternatively, you could extend `user-data` with other `cloud-init` [modules](https://cloudinit.readthedocs.io/en/latest/reference/modules.html#modules) to provision your image. + +Join the discussion on the [Multipass forum](https://discourse.ubuntu.com/c/multipass/) and let us know about your images! + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/customise-multipass/configure-multipasss-default-logging-level.md b/docs/how-to-guides/customise-multipass/configure-multipasss-default-logging-level.md new file mode 100644 index 0000000000..28783dcb37 --- /dev/null +++ b/docs/how-to-guides/customise-multipass/configure-multipasss-default-logging-level.md @@ -0,0 +1,93 @@ +# Configure Multipass’s default logging level +> See also: [Logging levels](/reference/logging-levels) + +This document demonstrates how to configure the default logging level of the Multipass service. Changing the logging level can be useful, for example, if you want to decrease the size of logging files or get more detailed information about what the daemon is doing. Logging levels can be set to one of the following: `error`, `warning`, `info`, `debug`, or `trace`, with case sensitivity. + +## Changing the default logging level + +[tabs] + +[tab version="Linux"] + +First, stop the Multipass daemon: + +```bash +sudo snap stop multipass +``` + +After that, create the override config file, replacing `` with your desired logging level: + +```bash +sudo mkdir /etc/systemd/system/snap.multipass.multipassd.service.d/ +sudo tee /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf < +EOF +sudo systemctl daemon-reload +``` + +Finally, start the Multipass daemon: + +```bash +sudo snap start multipass +``` + +[/tab] + +[tab version="macOS"] + +First, become `root`: + +```bash +sudo su +``` + +Stop the Multipass daemon: + +```bash +launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist +``` + +Then, open `/Library/LaunchDaemons/com.canonical.multipassd.plist` in your favorite [text editor](https://www.google.com/search?q=vi) and edit the path `/dict/array/string[2]` from `debug` to the logging level of your choice. + +Finally, start the Multipass daemon: + +```bash +launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist +``` + +[/tab] + +[tab version="Windows"] + +First, open an administrator privileged PowerShell prompt. + +Stop the Multipass service: + +```powershell +Stop-Service Multipass +``` + +Then, edit the Multipass service registry key with the following command: + +```powershell +Set-ItemProperty -path HKLM:\System\CurrentControlSet\Services\Multipass -Name ImagePath -Value "'C:\Program Files\Multipass\bin\multipassd.exe' /svc --verbosity " +``` + +Replacing `` with your desired logging level. + +Finally, start the Multipass service: + +```powershell +Start-Service Multipass +``` + +[/tab] + +[/tabs] + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/customise-multipass/configure-where-multipass-stores-external-data.md b/docs/how-to-guides/customise-multipass/configure-where-multipass-stores-external-data.md new file mode 100644 index 0000000000..57d04cd130 --- /dev/null +++ b/docs/how-to-guides/customise-multipass/configure-where-multipass-stores-external-data.md @@ -0,0 +1,288 @@ +# Configure where Multipass stores external data +This document demonstrates how to configure the location where Multipass stores instances, caches images, and other data. Configuring a new storage location can be useful, for example, if you need to free up storage space on your boot partition. + +## Configuring a new storage location + +```{caution} +**Caveats:** +- Multipass will not migrate your existing data; this article explains how to do it manually. If you do not transfer the data, you will have to re-download any Ubuntu images and reinitialize any instances that you need. +- When uninstalling Multipass, the uninstaller will not remove data stored in custom locations, so you'll have to deleted it manually. +``` + +[tabs] + +[tab version="Linux"] + +First, stop the Multipass daemon: + +```plain +sudo snap stop multipass +``` + +Since Multipass is installed using a strictly confined snap, it is limited on what it can do or access on your host. Depending on where the new storage directory is located, you will need to connect the respective interface to the Multipass snap. Because of [snap confinement](https://snapcraft.io/docs/snap-confinement), this directory needs to be located in either `/home` (connected by default) or one of the removable mounts points (`/mnt` or `/media`). To connect the removable mount points, use the command: + + ```plain + sudo snap connect multipass:removable-media + ``` + +Create the new directory in which Multipass will store its data: + +```plain +mkdir -p +sudo chown root +``` + +After that, create the override config file, replacing `` with the absolute path of the directory created above. + +```plain +sudo mkdir /etc/systemd/system/snap.multipass.multipassd.service.d/ +sudo tee /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf < +EOF +``` + +The output at this point will be: +```plain +[Service] +Environment=MULTIPASS_STORAGE= +``` + +Then, instruct `systemd` to reload the daemon configuration files: + +```plain +sudo systemctl daemon-reload +``` + +Now you can transfer the data from its original location to the new location: + +```plain +sudo cp -r /var/snap/multipass/common/data/multipassd /data +sudo cp -r /var/snap/multipass/common/cache/multipassd /cache +``` + + + +You also need to edit the following configuration files so that the specified paths point to the new Multipass storage directory, otherwise your instances will fail to start: + +* `multipass-vm-instances.json`: Update the absolute path of the instance images in the "arguments" key for each instance. +* `vault/multipassd-instance-image-records.json`: Update the "path" key for each instance. + +Finally, start the Multipass daemon: + +```plain +sudo snap start multipass +``` + +You can delete the original data at your discretion, to free up space: + +```plain +sudo rm -rf /var/snap/multipass/common/data/multipassd +sudo rm -rf /var/snap/multipass/common/cache/multipassd +``` + +[/tab] + +[tab version="macOS"] + +First, become `root`: + +```plain +sudo su +``` + +Stop the Multipass daemon: + +```plain +launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist +``` + +Move your current data from its original location to ``, replacing `` with your custom location of choice: + +```plain +mv /var/root/Library/Application\ Support/multipassd +``` + +```{caution} +Make sure the `multipassd` directory is moved to ``, and not inside the `` folder. +``` + +Define a symbolic link from the original location to the absolute path of new location: + +```plain +ln -s /var/root/Library/Application\ Support/multipassd +``` + +Finally, start the Multipass daemon: + +```plain +launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist +``` + +[/tab] + +[tab version="Windows"] + +First, open a PowerShell prompt with administration privileges. + +Stop the Multipass daemon: + +```powershell +Stop-Service Multipass +``` + +Create and set the new storage location, replacing `` with the absolute path of your choice: + +```powershell +New-Item -ItemType Directory -Path "" +Set-ItemProperty -Path "HKLM:System\CurrentControlSet\Control\Session Manager\Environment" -Name MULTIPASS_STORAGE -Value "" +``` + +Now you can transfer the data from its original location to the new location: + +```powershell +Copy-Item -Path "C:\ProgramData\Multipass\*" -Destination "" -Recurse +``` + +```{caution} +It is important to copy any existing data to the new location. This avoids unauthenticated client issues, permission issues, and in general, to have any previously created instances available. +``` + +Finally, start the Multipass daemon: + +```powershell +Start-Service Multipass +``` + +You can delete the original data at your discretion, to free up space: + +```powershell +Remove-Item -Path "C:\ProgramData\Multipass\*" -Recurse +``` + +[/tab] + +[/tabs] + +## Reverting back to the default location + +[tabs] + +[tab version="Linux"] + +Stop the Multipass daemon: + +```plain +sudo snap stop multipass +``` + +Although not required, to make sure that Multipass does not have access to directories that it shouldn't, you can disconnect the respective interface depending on where the custom storage location was set (see [Configuring a new storage location](#configuring-a-new-storage-location) above). For example, to disconnect the removable mounts points (`/mnt` or `/media`), run: + +```plain +sudo snap disconnect multipass:removable-media +``` + +Then, remove the override config file: + +```plain +sudo rm /etc/systemd/system/snap.multipass.multipassd.service.d/override.conf +sudo systemctl daemon-reload +``` + +Now you can transfer your data from the custom location back to its original location: + +```plain +sudo cp -r /data /var/snap/multipass/common/data/multipassd +sudo cp -r /cache /var/snap/multipass/common/cache/multipassd +``` + +Finally, start the Multipass daemon: + +```plain +sudo snap start multipass +``` + +You can delete the data from the custom location at your discretion, to free up space: + +```plain +sudo rm -rf +``` + +[/tab] + +[tab version="macOS"] + +First, become `root`: + +```plain +sudo su +``` + +Stop the Multipass daemon: + +```plain +launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist +``` + +Remove the link pointing to your custom location: + +```plain +unlink /var/root/Library/Application\ Support/multipassd +``` + +Move the data from your custom location back to its original location: + +```plain +mv /var/root/Library/Application\ Support/multipassd +``` + +Finally, start the Multipass daemon: + +```plain +launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist +``` + +[/tab] + +[tab version="Windows"] + +First, open a PowerShell prompt with administrator privileges. + +Stop the Multipass daemon: + +```powershell +Stop-Service Multipass +``` + +Remove the setting for the custom storage location: + +```powershell +Remove-ItemProperty -Path "HKLM:System\CurrentControlSet\Control\Session Manager\Environment" -Name MULTIPASS_STORAGE +``` + +Now you can transfer the data back to its original location: + +```powershell +Copy-Item -Path "\*" -Destination "C:\ProgramData\Multipass" -Recurse +``` + +Finally, start the Multipass daemon: + +```powershell +Start-Service Multipass +``` + +You can delete the data from the custom location at your discretion, to free up space: + +```powershell +Remove-Item -Path "" -Recurse +``` + +[/tab] + +[/tabs] + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/customise-multipass/how-to-integrate-with-windows-terminal.md b/docs/how-to-guides/customise-multipass/how-to-integrate-with-windows-terminal.md new file mode 100644 index 0000000000..42c374d955 --- /dev/null +++ b/docs/how-to-guides/customise-multipass/how-to-integrate-with-windows-terminal.md @@ -0,0 +1,45 @@ +# How to integrate with Windows Terminal +If you are on Windows and you want to use [Windows Terminal](https://aka.ms/terminal), Multipass can integrate with it to offer you an automatic `primary` profile. + +## Multipass profile + +Currently, Multipass can add a profile to Windows Terminal for the [primary instance](/t/28469#primary-instance). When you open a Windows Terminal tab with this profile, you'll automatically find yourself in a primary instance shell. Multipass automatically starts or launches the primary instance if needed. + +![screenshot-primary-shell|800x490, 85%](upload://zrYHMyoT4r9Xvz8DtFLH96uPfBu.png) + +## Install Windows Terminal + +The first step is to [install Windows Terminal](https://github.com/microsoft/terminal#installing-and-running-windows-terminal). Once you have it along [Multipass](https://multipass.run/docs/installing-on-windows), you can enable the integration. + +## Enable integration + +Open a terminal (Windows Terminal or any other) and enable the integration with the following command: + +``` +multipass set client.apps.windows-terminal.profiles=primary +``` + +The setting is documented [here](/reference/settings/client-apps-windows-terminal-profiles) for more info. Until you modify it, Multipass will try to add the profile if it finds it missing. To remove the profile see [Revert](#revert) below. + +## Open a Multipass tab + +You can now open a "Multipass" tab to get a shell in the primary instance. That can be achieved by clicking the new-tab drop-down and selecting the Multipass profile: + +![screenshot-dropdown|800x490, 85%](upload://tRzbGEZmSLvoM09kVgbG23BxU00.jpeg) + +That's it! + +## Revert + +If you want to disable the profile again, you can do so with: + +``` +multipass set client.apps.windows-terminal.profiles=none +``` + +Multipass will then remove the profile if it exists. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/customise-multipass/index.md b/docs/how-to-guides/customise-multipass/index.md new file mode 100644 index 0000000000..98a626f36f --- /dev/null +++ b/docs/how-to-guides/customise-multipass/index.md @@ -0,0 +1,30 @@ +# Customise-Multipass +The following guides provide step-by-step instructions on how to customise Multipass to address specific needs, from managing Multipass drivers to configuring a graphical user interface. + +- [Set up the driver](/how-to-guides/customise-multipass/set-up-the-driver) +- [Migrate from Hyperkit to QEMU on macOS](/how-to-guides/customise-multipass/migrate-from-hyperkit-to-qemu-on-macos) +- [Authenticate clients with the Multipass service](/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service) +- [Build Multipass images with Packer](/how-to-guides/customise-multipass/build-multipass-images-with-packer) +- [Set up a graphical interface](/how-to-guides/customise-multipass/set-up-a-graphical-interface) +- [Use a different terminal from the system icon](/how-to-guides/customise-multipass/use-a-different-terminal-from-the-system-icon) +- [Integrate with Windows Terminal](/how-to-guides/customise-multipass/how-to-integrate-with-windows-terminal) +- [Configure where Multipass stores external data](/how-to-guides/customise-multipass/configure-where-multipass-stores-external-data) +- [Configure Multipass’s default logging level](/how-to-guides/customise-multipass/configure-multipasss-default-logging-level) + + + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + + +```{toctree} +:hidden: +:titlesonly: +:maxdepth: 2 +:glob: + +* +*/index diff --git a/docs/how-to-guides/customise-multipass/migrate-from-hyperkit-to-qemu-on-macos.md b/docs/how-to-guides/customise-multipass/migrate-from-hyperkit-to-qemu-on-macos.md new file mode 100644 index 0000000000..6159acbd7d --- /dev/null +++ b/docs/how-to-guides/customise-multipass/migrate-from-hyperkit-to-qemu-on-macos.md @@ -0,0 +1,38 @@ +# Migrate from Hyperkit to QEMU on macOS +> See also: [`set`](/explanation/driver), [local.driver](/explanation/driver), [Driver](/explanation/driver), [How to set up the driver](/how-to-guides/customise-multipass/set-up-the-driver) + +As of Multipass 1.12, the Hyperkit driver is being deprecated. New installs will start with the QEMU driver set by default, but existing installs will retain the previous driver setting. Multipass will warn Hyperkit users of the deprecation and ask them to move to QEMU. To facilitate that, Multipass 1.12 will migrate Hyperkit instances to QEMU. + +To migrate from Hyperkit to QEMU and bring your instances along, simply stop them and set the driver to QEMU: + +``` +multipass stop --all +multipass set local.driver=qemu +``` + +If you already had QEMU instances, they are not affected by the migration. Instances whose name is taken on the QEMU side are not migrated. + +## Repeated driver switches + +The original Hyperkit instances are retained until explicitly deleted. You can achieve that by temporarily moving back to Hyperkit and using the delete command: + +``` +multipass set local.driver=hyperkit +multipass delete [-p] [...] +multipass set local.driver=qemu +``` + +When switching to QEMU again, migrated instances are not overwritten. If, for any reason, you want to repeat a migration, you can achieve that by deleting the QEMU counterpart first. + +You can choose a convenient time to do any of this and you can set the driver to Hyperkit and move back and forth as many times as you want. Apart from the deprecation warning, functionality remains the same until the driver is removed entirely. When that happens, it will no longer be possible to migrate Multipass (unless you downgrade to version 1.12). + +## Demo + +Here is a video demonstration of the migration: + +[![Hyperkit Migration in Multipass](https://asciinema.org/a/556203.svg)](https://asciinema.org/a/556203) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/customise-multipass/set-up-a-graphical-interface.md b/docs/how-to-guides/customise-multipass/set-up-a-graphical-interface.md new file mode 100644 index 0000000000..50b6a03a2a --- /dev/null +++ b/docs/how-to-guides/customise-multipass/set-up-a-graphical-interface.md @@ -0,0 +1,203 @@ +# Set up a graphical interface + + + + +You can display the graphical desktop in various ways. In this document, we describe two options: RDP (Remote Display Protocol) and plain X11 forwarding. Other methods include VNC and running a Mir shell through X11 forwarding, as described in [A simple GUI shell for a Multipass VM](/). + +## Using RDP + +The images used by Multipass do not come with a graphical desktop installed. For this reason, you will have to install a desktop environment (here we use `ubuntu-desktop` but there are as many other options as flavors of Ubuntu exist) along with the RDP server (we will use `xrdp` but there are also other options such as `freerdp`). + +To do this, first you need to log into a running Multipass instance. Start by listing your instances: + +```plain +multipass list +``` + +Sample output: + +```plain +Name State IPv4 Image +headbanging-squid Running 10.49.93.209 Ubuntu 22.04 LTS +``` + +Next, open a shell into the running instance: + +```plain +multipass shell headbanging-squid +``` + +Once inside the instance, run the following commands to install `ubuntu-desktop` and `xrdp`: + +```plain +sudo apt update +sudo apt install ubuntu-desktop xrdp +``` + +Now we need a user with a password to log in. One possibility is setting a password for the default `ubuntu` user: + +```plain +sudo passwd ubuntu +``` + +You will be asked to enter and re-enter a password. + +You are done on the server side! + +Quit the Ubuntu shell on the running instance with the `exit` command, and take note of the IP address to connect to. You can find the instance's IP address in the output of `multipass list` from the first step above, or you can use the `multipass info` command as well. + +```plain +multipass info headbanging-squid +``` + +Sample output: + +```plain +Name: headbanging-squid +State: Running +Snapshots: 0 +IPv4: 10.49.93.209 +Release: Ubuntu 22.04 LTS +Image hash: 2e0c90562af1 (Ubuntu 22.04 LTS) +CPU(s): 4 +Load: 0.00 0.00 0.00 +Disk usage: 1.8GiB out of 5.7GiB +Memory usage: 294.2MiB out of 3.8GiB +Mounts: -- +``` + +In this example, we will use the IP address `10.49.93.209` to connect to the RDP server on the instance. + +[note type="information"] +If the IP address of the instance is not displayed in the output of `multipass list`, you can obtain it directly from the instance, with the command `ip addr`. +``` + +[tabs] + +[tab version="Linux"] + +On Linux, there are applications such as Remmina to visualize the desktop (make sure the package `remmina-plugin-rdp` is installed in your host along with `remmina`). + +To directly launch the client, run the following command: + +```plain +remmina -c rdp://10.49.93.209 +``` + +The system will ask for a username (`ubuntu`) and the password set above, and then the Ubuntu desktop on the instance will be displayed. + +![Logging in to the RDP server with Remmina|690x567](upload://iNMPPVChbKiM2MIo7sGoHMLctcv.png) + +[/tab] + +[tab version="macOS"] + +To connect on MacOS, we can use the “Microsoft Remote Desktop” application, from the Mac App Store. + +[/tab] + +[tab version="Windows"] + +On Windows, we can connect to the RDP server with the “Remote Desktop Connection” application. There, we enter the virtual machine’s IP address, set the session to XOrg and enter the username and password we created on the previuos step. + +[/tab] + +[/tabs] + +And we are done… a graphical desktop! + +## Using X11 forwarding + +[tabs] + +It might be the case that we only want Multipass to launch one application and to see only that window, without having the need for a complete desktop. It turns out that this setup is simpler than the RDP approach, because we do not need the Multipass instance to deploy a full desktop. Instead, we can use X11 to connect the applications in the instance with the graphical capabilities of the host. + +[tab version="Linux"] + +Linux runs X by default, so no extra software in the host is needed. + +On Linux, we can use authentication in X forwarding to add a bit more security. However, we will forward through SSH to avoid struggling with `xauth`. Our user in the host will log in to the Multipass instance through SSH, so that we can pass extra parameters to it. + +To make this possible, copy your public key, stored in `~/.ssh/id_rsa.pub`, to the list of authorized keys of the instance, into the file `~/.ssh/authorized_keys`. Remember to replace the instance name used in the example with yours: + +```plain +multipass exec headbanging-squid -- bash -c "echo `cat ~/.ssh/id_rsa.pub` >> ~/.ssh/authorized_keys" +``` + +[note type=information] +If the file `~/.ssh/id_rsa.pub` does not exist, it means that you need to create your SSH keys. Use `ssh-keygen` to create them and then run the previous command again. +``` + +Check the IP address of the instance, using `multipass info headbanging-squid` Finally, log in to the instance using X forwarding using the command (replace `xx.xx.xx.xx` with the IP address obtained above): + +```plain +ssh -X ubuntu@xx.xx.xx.xx +``` + +Test the setting running a program of your choice on the instance; for example: + +```plain +sudo apt -y install x11-apps +xlogo & +``` + +![xlogo on Linux|420x455](upload://etvJU6k1tfuZ0QsKd4TZM1ogsgR.png) + +A small window containing the X logo will show up. Done! + +[/tab] + +[tab version="macOS"] + +The first step in Mac is to make sure a X server is running. The easiest way is to install [XQuartz](https://www.xquartz.org). + +Once the X server is running, the procedure for macOS is the same as for Linux. + +[note type="information"] +Note to Apple Silicon users: some applications requiring OpenGL will not work through X11 forwarding. +``` + +[/tab] + +[tab version="Windows"] + +Windows knows nothing about X, therefore we need to install an X server. Here we will use [VcXsrv](https://sourceforge.net/projects/vcxsrv/). Other options would be [Xming](http://www.straightrunning.com/XmingNotes/) (the newest versions are paid, but older versions can still be downloaded for free from their [SourceForge site](https://sourceforge.net/projects/xming/)) or installing an X server in [Cygwin](http://cygwin.com/). + +The first step would be thus to install VcXsrv and run the X server through the newly created start menu entry "XLaunch". Some options will be displayed. In the first screen, select "Multiple windows" and set the display number; leaving it in -1 is a safe option. The "Next" button brings you to the "Client startup" window, where you should select "Start no client". Click "Next" to go to the "Extra settings" screen, where you should activate the option "Disable access control". When you click "Next" you will be given the option to save the settings, and finally you can start the X server. + +An icon will show up in the dock: you are done with the X server! + +To configure the client (that is, the Multipass instance) you will need the host IP address; you can obtain it with the console command `ipconfig`. + +Then, start the instance and set the `DISPLAY` environment variable to the server display on the host IP (replace `xx.xx.xx.xx` with the IP address obtained above): + +```plain +export DISPLAY=xx.xx.xx.xx:0.0 +``` + +You are done, and you can now test forwarding running a program of your choice on the instance; for example: + +```plain +sudo snap install firefox +firefox & +``` + +![Firefox running on the Multipass instance|690x388](upload://iy5xIwIRyMXjYqyhefIfdDoXnAi.jpeg) + +[/tab] + +[/tabs] + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- +**Contributors:** @andreitoterman , @luisp , @ricab , @gzanchi @dan-roscigno + diff --git a/docs/how-to-guides/customise-multipass/set-up-the-driver.md b/docs/how-to-guides/customise-multipass/set-up-the-driver.md new file mode 100644 index 0000000000..6ac9fb004f --- /dev/null +++ b/docs/how-to-guides/customise-multipass/set-up-the-driver.md @@ -0,0 +1,114 @@ +# Set up the driver +> See also: [Driver](/explanation/driver), [`local.driver`](/reference/settings/local-driver) + +This document demonstrates how to choose, set up, and manage the drivers behind Multipass. Multipass already has sensible defaults, so this is an optional step. + +## Default driver + +[tabs] + +[tab version="Linux"] + +By default, Multipass on Linux uses the `qemu` or `lxd` driver (depending on the architecture). + +[/tab] + +[tab version="macOS"] + +By default, Multipass on macOS uses the `qemu` driver. + +[/tab] + +[tab version="Windows"] + +By default, Multipass on Windows uses the `hyperv` driver. + +[/tab] + +[/tabs] + +## Install an alternative driver + +[tabs] + +[tab version="Linux"] + +If you want more control over your VMs after they are launched, you can also use the experimental [libvirt](https://libvirt.org/) driver. + +To install libvirt, run the following command (or use the equivalent for your Linux distribution): + +```plain +sudo apt install libvirt-daemon-system +``` + +Now you can switch the Multipass driver to libvirt. First, enable Multipass to use your local libvirt by connecting to the libvirt interface/plug: + +```plain +sudo snap connect multipass:libvirt +``` + +Then, stop all instances and tell Multipass to use libvirt, running the following commands: + +```plain +multipass stop --all +multipass set local.driver=libvirt +``` + +All your existing instances will be migrated and can be used straight away. + +[note type="information"] +You can still use the `multipass` client and the tray icon, and any changes you make to the configuration of the instance in libvirt will be persistent. They may not be represented in Multipass commands such as `multipass info`, though. +``` + +[/tab] + +[tab version="macOS"] + +An alternative option is to use VirtualBox. + +To switch the Multipass driver to VirtualBox, run this command: + +```plain +sudo multipass set local.driver=virtualbox +``` + +From now on, all instances started with `multipass launch` will use VirtualBox behind the scenes. + +[/tab] + +[tab version="Windows"] + +If you want to (or have to), you can change the hypervisor that Multipass uses to VirtualBox. + +To that end, install VirtualBox, if you haven't yet. You may find that you need to [run the VirtualBox installer as administrator](https://forums.virtualbox.org/viewtopic.php?f=6&t=88405#p423658). + +To switch the Multipass driver to VirtualBox (also with Administrator privileges), run this command: + +```powershell +multipass set local.driver=virtualbox +``` + +From then on, all instances started with `multipass launch` will use VirtualBox behind the scenes. + +[/tab] + +[/tabs] + +## Use the driver to view Multipass instances + +[tabs] + +[tab version="Linux"] + +You can view instances with libvirt in two ways, using the `virsh` CLI or the [`virt-manager` GUI](https://virt-manager.org/). + +To use the `virsh` CLI, launch an instance and then run the command `virsh list` (see [`man virsh`](http://manpages.ubuntu.com/manpages/xenial/man1/virsh.1.html) for a command reference): + +```plain +virsh list +``` + +The output will be similar to the following: + +```plain + Id Name State diff --git a/docs/how-to-guides/customise-multipass/use-a-different-terminal-from-the-system-icon.md b/docs/how-to-guides/customise-multipass/use-a-different-terminal-from-the-system-icon.md new file mode 100644 index 0000000000..14968a29b0 --- /dev/null +++ b/docs/how-to-guides/customise-multipass/use-a-different-terminal-from-the-system-icon.md @@ -0,0 +1,40 @@ +# Use a different terminal from the system icon +> See also: [How to install Multipass](/how-to-guides/install-multipass), [`shell`](/reference/command-line-interface/shell). + +If you want, you can change the terminal application used by the Multipass system menu icon. + +[note type='information'] +Currently available only for macOS +``` + +To do so, you need to tell macOS which terminal to use for the `.command` file type. This document presents two ways of achieving this. + +## Using `duti` + +[`duti`](https://github.com/moretension/duti/) is a small helper application that can modify the default application preferences. It's also [available from `brew`](https://formulae.brew.sh/formula/duti). + +Find out your preferred terminal's bundle identifier using `mdls`: + +```console +mdls /Applications/iTerm.app/ | grep BundleIdentifier +kMDItemCFBundleIdentifier = "com.googlecode.iterm2" +``` + +And make it the default for script files using `duti`: + +```console +duti -s com.googlecode.iTerm2 com.apple.terminal.shell-script shell +``` + +## Using Finder + +Create an empty file with a `.command` extension and find it in Finder. Select the file and press `⌘I`. You should be presented with an information pane like this: + +![obraz|289x366](upload://47AaFCBSwPTDyEAbMjKkclk8DfA.png) + +Expand the "Open with:" section, select your preferred terminal application and click on "Change All…". + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/index.md b/docs/how-to-guides/index.md new file mode 100644 index 0000000000..28eacb52f3 --- /dev/null +++ b/docs/how-to-guides/index.md @@ -0,0 +1,65 @@ +# How-To-Guides +The following how-to guides provide step-by-step instructions on the installation, use, management and troubleshooting of Multipass. + +## Install and deploy Multipass + +Installing Multipass is a straightforward process but may require some prerequisiste steps, depending on your host system. You can find specific installation instructions for your operating system in this guide: +- [How to install Multipass](/how-to-guides/install-multipass) + +## Manage instances + +Multipass allows you to create Ubuntu instances with a single command. As your needs grow, you can modify and customise instances as well as use and create blueprints for customised instances: + +- [Create an instance](/how-to-guides/manage-instances/create-an-instance) +- [Modify an instance](/how-to-guides/manage-instances/modify-an-instance) +- [Use an instance](/how-to-guides/manage-instances/use-an-instance) +- [Use the primary instance](/how-to-guides/manage-instances/use-the-primary-instance) +- [Use instance command aliases](/how-to-guides/manage-instances/use-instance-command-aliases) +- [Share data with an instance](/how-to-guides/manage-instances/share-data-with-an-instance) +- [Remove an instance](/how-to-guides/manage-instances/remove-an-instance) +- [Add a network to an existing instance](/how-to-guides/manage-instances/add-a-network-to-an-existing-instance) +- [Configure static IPs](/how-to-guides/manage-instances/configure-static-ips) +- [Use a blueprint](/how-to-guides/manage-instances/use-a-blueprint) +- [Use the Docker blueprint](/how-to-guides/manage-instances/use-the-docker-blueprint) +- [Run a Docker container in Multipass](/how-to-guides/manage-instances/run-a-docker-container-in-multipass) + +## Customise Multipass + +You may also want to customise Multipass to address specific needs, from managing Multipass drivers to configuring a graphical user interface: + +- [Set up the driver](/how-to-guides/customise-multipass/set-up-the-driver) +- [Migrate from Hyperkit to QEMU on macOS](/how-to-guides/customise-multipass/migrate-from-hyperkit-to-qemu-on-macos) +- [Authenticate clients with the Multipass service](/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service) +- [Build Multipass images with Packer](/how-to-guides/customise-multipass/build-multipass-images-with-packer) +- [Set up a graphical interface](/how-to-guides/customise-multipass/set-up-a-graphical-interface) +- [Use a different terminal from the system icon](/how-to-guides/customise-multipass/use-a-different-terminal-from-the-system-icon) +- [Integrate with Windows Terminal](/how-to-guides/customise-multipass/how-to-integrate-with-windows-terminal) +- [Configure where Multipass stores external data](/how-to-guides/customise-multipass/configure-where-multipass-stores-external-data) +- [Configure Multipass’s default logging level](/how-to-guides/customise-multipass/configure-multipasss-default-logging-level) + + + +## Troubleshoot + +Use the following how-to guides to troubleshoot issues with your Multipass installation, beginning by inspecting the logs: + +- [Access logs](/how-to-guides/troubleshoot/access-logs) +- [Mount an encrypted home folder](/how-to-guides/troubleshoot/mount-an-encrypted-home-folder) +- [Troubleshoot launch/start issues](/how-to-guides/troubleshoot/troubleshoot-launch-start-issues) +- [Troubleshoot networking](/how-to-guides/troubleshoot/troubleshoot-networking) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + + +```{toctree} +:hidden: +:titlesonly: +:maxdepth: 2 +:glob: + +* +*/index diff --git a/docs/how-to-guides/install-multipass.md b/docs/how-to-guides/install-multipass.md new file mode 100644 index 0000000000..28a0c40a02 --- /dev/null +++ b/docs/how-to-guides/install-multipass.md @@ -0,0 +1,250 @@ +# Install Multipass + + + + +This guide explains how to install and manage Multipass on your system. + +[note type="information"] +Select the tab corresponding to your operating system (e.g. Linux) to display the relevant content in each section. Your decision will stick until you select another OS from the drop-down menu. +``` + +## Check prerequisites + +[tabs] + +[tab version="Linux"] + +Multipass for Linux is published as a [snap package](https://snapcraft.io/docs/), available on the [Snap Store](https://snapcraft.io/multipass). Before you can use it, you need to [install `snapd`](https://docs.snapcraft.io/core/install). `snapd` is included in Ubuntu by default. + +[/tab] + +[tab version="macOS"] + + + +The default backend on macOS is `qemu`, wrapping Apple's Hypervisor framework. You can use any Mac (M1, M2, or Intel based) with **macOS 10.15 Catalina or later** installed. + +[/tab] + +[tab version="Windows"] + +### Hyper-V + +Only **Windows 10 Pro** or **Enterprise** version **1803** ("April 2018 Update") **or later** are currently supported, due to the necessary version of Hyper-V only being available on those versions. + +### VirtualBox + +Multipass also supports using VirtualBox as a virtualization provider. You can download the latest version from the [VirtualBox download page](https://www.oracle.com/technetwork/server-storage/virtualbox/downloads/index.html). + +[/tab] + +[/tabs] + +## Install + +[tabs] + +[tab version="Linux"] + +To install Multipass, run the following command: + +```plain +snap install multipass +``` + +You can also use the `edge` channel to get the latest development build: + +```plain +snap install multipass --edge +``` + +Make sure you're part of the group that Multipass gives write access to its socket (`sudo` in this case, but it may also be `wheel` or `admin`, depending on your distribution). + +1. Run this command to check which group is used by the Multipass socket: + ```plain + ls -l /var/snap/multipass/common/multipass_socket + ``` + The output will be similar to the following: + ```plain + srw-rw---- 1 root sudo 0 Dec 19 09:47 /var/snap/multipass/common/multipass_socket + ``` + +2. Run the `groups` command to make sure you are a member of that group (in our example, "sudo"): + + ```plain + groups | grep sudo + ``` + The output will be similar to the following: + ```plain + adm cdrom sudo dip plugdev lpadmin + ``` + +You can view more information on the snap package using the `snap info` command: + +```plain +snap info multipass +``` +For example: +```plain +name: multipass +summary: Instant Ubuntu VMs +publisher: Canonical✓ +store-url: https://snapcraft.io/multipass +contact: https://github.com/CanonicalLtd/multipass/issues/new +license: GPL-3.0 +description: | + Multipass is a tool to launch and manage VMs on Windows, Mac and Linux that simulates a cloud + environment with support for cloud-init. Get Ubuntu on-demand with clean integration to your IDE + and version control on your native platform. + ... +commands: + - multipass.gui + - multipass +services: + multipass.multipassd: simple, enabled, active +snap-id: mA11087v6dR3IEcQLgICQVjuvhUUBUKM +tracking: latest/candidate +refresh-date: 5 days ago, at 10:13 CEST +channels: + latest/stable: 1.3.0 2020-06-17 (2205) 228MB - + latest/candidate: 1.3.0 2020-06-17 (2205) 228MB - + latest/beta: 1.3.0-dev.17+gf89e1db 2020-04-28 (2019) 214MB - + latest/edge: 1.4.0-dev.83+g149f10a 2020-06-17 (2216) 228MB - +installed: 1.3.0 (2205) 228MB - +``` + +[/tab] + +[tab version="macOS"] + +[note type=information] +You will need an account with administrator privileges to complete the installation. +``` + +Download the latest installer from [our download page](https://multipass.run/download/macos). You can also get pre-release versions from the [GitHub releases](https://github.com/canonical/multipass/releases/) page, look for the `.pkg` package. + +Run the downloaded installer and follow the guided procedure. + +![Multipass installer on macOS|658x475](upload://oBqM17GtMd6dzpBJ2OWl3fexIP2.png) + +[/tab] + +[tab version="Windows"] + +[note type=information] +You will need either Hyper-V enabled (only Windows 10 Professional or Enterprise), or VirtualBox installed. See [Check prerequisites](#check-prerequisites). +``` + +Download the latest installer from [our download page](https://multipass.run/download/windows). You can also get pre-release versions from the [GitHub releases](https://github.com/CanonicalLtd/multipass/releases/) page, look for the `.msi` file. + +Run the downloaded installer and follow the guided procedure. The installer will require to be granted Administrator privileges. + +[/tab] + +Alternatively, you can also check your preferred package manager to see if it provides Multipass, although this option is not officially supported. + +[/tabs] + +## Run + +[tabs] + +[tab version="Linux"] + +You've installed Multipass. Time to run your first commands! Use `multipass version` to check your version or `multipass launch` to create your first instance. + +[/tab] + +[tab version="macOS"] + +You've installed Multipass. Time to run your first commands! Use `multipass version` to check your version or `multipass launch` to create your first instance. + +> See also: [How to set up the driver](/how-to-guides/customise-multipass/set-up-the-driver), [How to use a different terminal from the system icon](/how-to-guides/customise-multipass/use-a-different-terminal-from-the-system-icon) + +[/tab] + +[tab version="Windows"] + +You've installed Multipass. Time to run your first commands! Launch a **Command Prompt** (`cmd.exe`) or **PowerShell** as a regular user. Use `multipass version` to check your version or `multipass launch` to create your first instance. + +Multipass defaults to using Hyper-V as its virtualization provider. If you'd like to use VirtualBox, you can do so using the following command: + +```plain +multipass set local.driver=virtualbox +``` + +> See also: [How to set up the driver](/how-to-guides/customise-multipass/set-up-the-driver). + +[/tab] + +[/tabs] + +## Upgrade + +[tabs] + +[tab version="Linux"] + +As the installation happened via snap, you don't need to worry about upgrading---it will be done automatically. + +[/tab] + +[tab version="macOS"] + +[note type=information] +You will need an account with administrator privileges to complete the upgrade. +``` + +To upgrade, download the latest installer from [our download page](https://multipass.run/download/macos). You can also get pre-release versions from the [GitHub releases](https://github.com/canonical/multipass/releases/) page, look for the `.pkg` package. + +Run the downloaded installer and follow the guided procedure. + +Any existing instances will be preserved. + +[/tab] + +[tab version="Windows"] + +To upgrade, [download the latest installer](https://multipass.run/download/windows) and run it. You can also get pre-release versions from the [GitHub releases](https://github.com/canonical/multipass/releases/) page, look for the `.msi` package. + +You will be asked to uninstall the old version, and then whether to remove all data when uninstalling. If you want to keep your existing instances, answer "No" (default). +[/tab] + +[/tabs] + +## Uninstall + +[tabs] + +[tab version="Linux"] +To uninstall Multipass, run the following command: + +```plain +snap remove multipass +``` +[/tab] + +[tab version="macOS"] + +To uninstall Multipass, run the script: +```plain +sudo sh "/Library/Application Support/com.canonical.multipass/uninstall.sh" +``` + +[/tab] + +[tab version="Windows"] +Uninstall Multipass as you would any other program, following the usual procedure. +[/tab] + +[/tabs] + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @saviq , @townsend , @sowasred2012 , @ya-bo-ng , @shuuji3 , @henryschreineriii , @sven , @nick3499 , @undefynd , @sparkiegeek , @nottrobin , @tmihoc , @nhart , @luisp , @sharder996 , @aaryan-porwal , @andreitoterman , @ricab , @gzanchi , @bagustris + diff --git a/docs/how-to-guides/manage-instances/add-a-network-to-an-existing-instance.md b/docs/how-to-guides/manage-instances/add-a-network-to-an-existing-instance.md new file mode 100644 index 0000000000..96612e0bc6 --- /dev/null +++ b/docs/how-to-guides/manage-instances/add-a-network-to-an-existing-instance.md @@ -0,0 +1,59 @@ +# Add a network to an existing instance +> See also: [`networks`](/reference/command-line-interface/networks), [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`local..bridged`](/reference/settings/local-instance-name-bridged) + +This guide explains how to bridge an existing Multipass instance with the available networks. + +```{caution} +This feature is available starting from Multipass version 1.14. +``` + +First, you need to select a Multipass-wide preferred network to bridge with (you can always change it later). To do so, list all available networks using the [`multipass networks`](/reference/command-line-interface/networks) command. The output will be similar to the following: + +```plain +Name Type Description +br-eth0 bridge Network bridge with eth0 +br-eth1 bridge Network bridge with eth1 +eth0 ethernet Ethernet device +eth1 ethernet Ethernet device +lxdbr0 bridge Network bridge +mpbr0 bridge Network bridge for Multipass +virbr0 bridge Network bridge +``` + +Set the preferred network (for example, `eth0`) using the [`multipass set`](/reference/command-line-interface/set) command: + +```plain +multipass set local.bridged-network=eth0 +``` + +Before bridging the network, you need to stop the instance (called `ultimate-grosbeak` in our example) using the [`multipass stop`](/reference/command-line-interface/stop) command: + +```plain +multipass stop ultimate-grosbeak +``` + +You can now ask Multipass to bridge your preferred network using the [`local..bridged`](/reference/settings/local-instance-name-bridged) setting: + +```plain +multipass set local.ultimate-grosbeak.bridged=true +``` + +To add further networks, update the preferred bridge and repeat: + +```plain +multipass set local.bridged-network=eth1 +multipass set local.ultimate-grosbeak.bridged=true +``` + +Use the [`multipass get`](/reference/command-line-interface/get) command to check whether an instance is bridged with the currently configured preferred network: + +```plain +multipass get local.ultimate-grosbeak.bridged +``` + +After following the recipe above, the result should be `true`. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/configure-static-ips.md b/docs/how-to-guides/manage-instances/configure-static-ips.md new file mode 100644 index 0000000000..aa1a8cb44b --- /dev/null +++ b/docs/how-to-guides/manage-instances/configure-static-ips.md @@ -0,0 +1,101 @@ +# Configure static IPs +> See also: [Instance](/explanation/instance) + +This guide explains how to create instances with static IPs in a new network, internal to the host. With this approach, instances get an extra IP that does not change with restarts. By using a separate, local network we avoid any IP conflicts. Instances retain the usual default interface with a DHCP-allocated IP, which gives them connectivity to the outside. + +## Step 1: Create a Bridge + +The first step is to create a new bridge/switch with a static IP on your host. + +This is beyond the scope of Multipass but, as an example, here is how this can be achieved with NetworkManager on Linux (e.g. on Ubuntu Desktop): + +``` +nmcli connection add type bridge con-name localbr ifname localbr \ + ipv4.method manual ipv4.addresses 10.13.31.1/24 +``` + +This will create a bridge named `localbr` with IP `10.13.31.1/24`. You can see the new device and address with `ip -c -br addr show dev localbr`. This should show: + +``` +localbr DOWN 10.13.31.1/24 +``` + +You can also run `multipass networks` to confirm the bridge is available for Multipass to connect to. + +## Step 2: Launch an instance with a manual network + +Next we launch an instance with an extra network in manual mode, connecting it to this bridge: + +``` +multipass launch --name test1 --network name=localbr,mode=manual,mac="52:54:00:4b:ab:cd" +``` + +You can also leave the MAC address unspecified (just `--network name=localbr,mode=manual`). If you do so, Multipass will generate a random MAC for you, but you will need to retrieve it in the next step. + +## Step 3: Configure the extra interface + +We now need to configure the manual network interface inside the instance. We can achieve that using Netplan. The following command plants the required Netplan configuration file in the instance: + +``` +multipass exec -n test1 -- sudo bash -c 'cat << EOF > /etc/netplan/10-custom.yaml +network: + version: 2 + ethernets: + extra0: + dhcp4: no + match: + macaddress: "52:54:00:4b:ab:cd" + addresses: [10.13.31.13/24] +EOF' +``` + +The IP address needs to be unique and in the same subnet as the bridge. The MAC address needs to match the extra interface inside the instance: either the one provided in step 2 or the one Multipass generated (you can find it with `ip link`). + +If you want to set a different name for the interface, you can add a [`set-name` property](https://netplan.readthedocs.io/en/stable/netplan-yaml/#properties-for-physical-device-types). + +## Step 4: Apply the new configuration + +We now tell `netplan` apply the new configuration inside the instance: + +``` +multipass exec -n test1 -- sudo netplan apply +``` + +You may also use `netplan try`, to have the outcome reverted if something goes wrong. + +## Step 5: Confirm that it works + +You can confirm that the new IP is present in the instance with Multipass: + +``` +multipass info test1 +``` + +The command above should show two IPs, the second of which is the one we just configured (`10.13.31.13`). You can use `ping` to confirm that it can be reached from the host: + +``` +ping 10.13.31.13 +``` + +Conversely, you can also ping from the instance to the host: + +``` +multipass exec -n test1 -- ping 10.13.31.1 +``` + +## Step 6: More instances + +If desired, repeat steps 2-5 with different names/MACs/IP terminations (e.g. `10.13.31.14`) to launch other instances with static IPs in the same network. You can ping from one instance to another to confirm that they are connected. For example: + +``` +multipass exec -n test1 -- ping 10.13.31.14 +``` + +## Conclusion + +You have now created a small internal network, local to your host, with Multipass instances that you can reach on the same IP across reboots. Instances still have the default NAT-ed network, which they can use to reach the outside world. You can combine this with other networks if you want to (e.g. for bridging). + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/create-an-instance.md b/docs/how-to-guides/manage-instances/create-an-instance.md new file mode 100644 index 0000000000..3d06c0ec62 --- /dev/null +++ b/docs/how-to-guides/manage-instances/create-an-instance.md @@ -0,0 +1,283 @@ +# Create an instance +> See also: [`launch`](/reference/command-line-interface/launch), [Instance](/explanation/instance) + +This document demonstrates various ways to create an instance with Multipass. While every method is a one-liner involving the command `multipass launch`, each showcases a different option that you can use to get exactly the instance that you want. + +## Create an instance + +> See also: [`launch`](/reference/command-line-interface/launch), [`info`](/reference/command-line-interface/info) + +To create an instance with Multipass, run the command `multipass launch`. This launches a new instance, which is randomly named; for example: + +```plain +… +Launched: keen-yak +``` + +In particular, when we run `multipass info keen-yak`, we find out that it is an Ubuntu LTS release, namely 18.04, with 1GB RAM, 1 CPU, 5GB of disk: + +```plain +Name: keen-yak +State: RUNNING +IPv4: 10.140.94.253 +Release: Ubuntu 18.04.1 LTS +Image hash: d53116c67a41 (Ubuntu 18.04 LTS) +CPU(s): 1 +Load: 0.00 0.12 0.18 +Disk usage: 1.1G out of 4.7G +Memory usage: 71.6M out of 985.4M +``` + +## Create an instance with a specific image + +> See also: [`find`](/reference/command-line-interface/find), [`launch `](/reference/command-line-interface/launch), [`info`](/reference/command-line-interface/info) + +To find out which images are available, run `multipass find`. Here's a sample output: + +```plain +Image Aliases Version Description +20.04 focal 20240821 Ubuntu 20.04 LTS +22.04 jammy 20240912 Ubuntu 22.04 LTS +24.04 noble,lts 20240911 Ubuntu 24.04 LTS + +Blueprint Aliases Version Description +anbox-cloud-appliance latest Anbox Cloud Appliance +charm-dev latest A development and testing environment for charmers +docker 0.4 A Docker environment with Portainer and related tools +jellyfin latest Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media. +minikube latest minikube is local Kubernetes +ros-noetic 0.1 A development and testing environment for ROS Noetic. +ros2-humble 0.1 A development and testing environment for ROS 2 Humble. +``` + +To launch an instance with a specific image, include the image name or alias in the command, for example `multipass launch jammy`: + +```plain +... +Launched: tenacious-mink +``` + +`multipass info tenacious-mink` confirms that we've launched an instance of the selected image. + +```plain +Name: tenacious-mink +State: Running +Snapshots: 0 +IPv4: 192.168.64.22 +Release: Ubuntu 22.04.5 LTS +Image hash: e898c1c93b32 (Ubuntu 22.04 LTS) +CPU(s): 1 +Load: 0.00 0.02 0.01 +Disk usage: 1.6GiB out of 4.8GiB +Memory usage: 149.5MiB out of 962.2MiB +Mounts: -- +``` + +## Create an instance with a custom name + +> See also: [`launch --name`](/reference/command-line-interface/launch) + +To launch an instance with a specific name, add the `--name` option to the command line; for example `multipass launch kinetic --name helpful-duck`: + +```plain +... +Launched: helpful-duck +``` + +## Create an instance with custom CPU number, disk and RAM + +> See also: [`launch --cpus --disk --memory`](/reference/command-line-interface/launch) + +You can specify a custom number of CPUs, disk and RAM size using the `--cpus`, `--disk` and `--memory` arguments, respectively. For example: + +```plain +multipass launch --cpus 4 --disk 20G --memory 8G +``` + +## Create an instance with primary status + +> See also: [`launch --name primary`](/reference/command-line-interface/launch) + +An instance can obtain the primary status at creation time if its name is `primary`: + +```plain +multipass launch kinetic --name primary +``` + +For more information, see: [How to use the primary instance](/how-to-guides/manage-instances/use-the-primary-instance). + +## Create an instance with multiple network interfaces + +> See also: [`launch --network`](/reference/command-line-interface/launch) + +Multipass can create instances with additional network interfaces using the `multipass launch` command with the `--network` option. This is complemented by the [`networks`](/reference/command-line-interface/networks) command, that you can use to find available host networks to bridge with. + +This feature is only supported for images with [`cloud-init` support for v2 network config](https://cloudinit.readthedocs.io/en/latest/topics/network-config-format-v2.html), which in turn requires [netplan](https://netplan.io/) to be installed, meaning that you'll require Ubuntu 17.10 and Ubuntu Core 16 (except `snapcraft:core16`) or later. More specifically, this feature is only supported in the following scenarios: + +* on Linux, with LXD +* on Windows, with both Hyper-V and [VirtualBox](https://multipass.run/docs/using-virtualbox-in-multipass-windows) +* on macOS, with the QEMU and [VirtualBox](https://multipass.run/docs/using-virtualbox-in-multipass-macos) drivers + +The `--network` option can be given multiple times to request multiple network interfaces beyond the default one, which is always present. Each time you add the `--network` option you also need to provide an argument specifying the properties of the desired interface: + +- `name` - This is the only required value, used to identify the host network to connect the instance's device to (see [`networks`](/reference/command-line-interface/networks) for possible values). +- `mode` - Either `auto` (default) or `manual`; with `auto`, the instance will attempt to configure the network automatically. +- `mac` - Custom MAC address to use for the device. + +These properties can be specified in the format `=` but a simpler form with only `` is available for the most common use case. Here is an example: + +```plain +multipass launch --network en0 --network name=bridge0,mode=manual +``` + +You can inspect the IP addresses assigned to the network interfaces of the new instance ("upbeat-whipsnake) on the system using the command: + +```plain +multipass exec upbeat-whipsnake -- ip -br address show scope global +``` + +Sample output: + +```plain +enp0s3 UP 10.0.2.15/24 +enp0s8 UP 192.168.1.146/24 +enp0s9 DOWN +``` + +Last, you can run `ping -c1 192.168.1.146` from the same network to verify that the IP can be reached: + +```plain +PING 192.168.1.146 (192.168.1.146): 56 data bytes +64 bytes from 192.168.1.146: icmp_seq=0 ttl=64 time=0.378 ms +... +``` + +In the example above, we got the following interfaces inside the instance: +- `enp0s3` - The default interface, that the instance can use to reach the outside world and that Multipass uses to communicate with the instance. +- `enp0s8` - The interface that is connected to `en0` on the host and that is automatically configured. +- `enp0s9` - The interface that is connected to `bridge0` on the host, ready for manual configuration. + +### Routing + +Extra interfaces are configured with a higher metric (200) than the default one (100). So, by default the instance will only route through them if they're a better match for the destination IP (see [Wikipedia | Longest_prefix-match](https://en.wikipedia.org/wiki/Longest_prefix_match). + +For example, if the command `multipass exec upbeat-whipsnake -- ip route` returns the following routing table: + +```plain +default via 10.0.2.2 dev enp0s3 proto dhcp src 10.0.2.15 metric 100 +default via 192.168.1.1 dev enp0s8 proto dhcp src 192.168.1.146 metric 200 +10.0.2.0/24 dev enp0s3 proto kernel scope link src 10.0.2.15 +10.0.2.2 dev enp0s3 proto dhcp scope link src 10.0.2.15 metric 100 +192.168.1.0/24 dev enp0s8 proto kernel scope link src 192.168.1.146 +192.168.1.1 dev enp0s8 proto dhcp scope link src 192.168.1.146 metric 200 +``` + +you can then explore how specific IPs are routed: + +```plain +multipass exec upbeat-whipsnake -- ip route get 91.189.88.181 +``` + +In this case, for example: +```plain +91.189.88.181 via 10.0.2.2 dev enp0s3 src 10.0.2.15 uid 1000 + cache +``` + +### Bridging + +On Linux, when trying to connect an instance network to an ethernet device on the host, Multipass will offer to create the required bridge. + +First, run the `multipass networks` command; for example: + +```plain +Name Type Description +eth0 ethernet Ethernet device +lxdbr0 bridge Network bridge +mpbr0 bridge Network bridge for Multipass +virbr0 bridge Network bridge +``` + +Then, select an ethernet device and launch a new instance requesting to connect to it, for example via `multipass launch --network eth0`. The output will be: + +```plain +Multipass needs to create a bridge to connect to eth0. +This will temporarily disrupt connectivity on that interface. + +Do you want to continue (yes/no)? +``` + +However, Multipass requires `NetworkManager` to achieve this. On installations that do not have `NetworkManager` installed (e.g. Ubuntu Server), the user can still create a bridge by other means and pass that to Multipass. For instance, this configuration snippet achieves that with `netplan`: + +```yaml +network: + bridges: + mybridge: + dhcp4: true + interfaces: + - eth0 +``` + +That goes somewhere in `/etc/netplan/` (e.g. `/etc/netplan/50-custom.yaml`). After a successful `netplan try` or `netplan apply`, Multipass will show the new bridge with the `networks` command and instances can be connected to it: + +```plain +multipass launch --network mybridge +``` + +Another option is to install `NetworkManager`, but other network handlers need to be deactivated to avoid conflicts and make the new bridges permanent. + +## Create an instance with a custom DNS + +In some scenarios the default of using the system-provided DNS will not be sufficient. When that's the case, you can use the `--cloud-init` option to the [`launch`](/reference/command-line-interface/launch) command, or modify the networking configuration after the instance started. + +### The `--cloud-init` approach + +> See also: [`launch --cloud-init`](/reference/command-line-interface/launch) + +To use a custom DNS in your instances, you can use this `cloud-init` snippet: + +```yaml +#cloud-config +bootcmd: +- printf "[Resolve]\nDNS=8.8.8.8" > /etc/systemd/resolved.conf +- [systemctl, restart, systemd-resolved] +``` + +Replace `8.8.8.8` with whatever your preferred DNS server is. You can then launch the instance using the following command: + +```bash +multipass launch --cloud-init systemd-resolved.yaml +``` + +### The netplan\.io approach + +After the instance booted, you can modify the `/etc/netplan/50-cloud-init.yaml` file, adding the `nameservers` entry: + +```yaml +network: + ethernets: + ens3: + dhcp4: true + match: + macaddress: 52:54:00:fe:52:ee + set-name: ens3 + nameservers: + search: [mydomain] + addresses: [8.8.8.8] +``` + +You can then test it with the command `sudo netplan try`: + +```plain +Do you want to keep these settings? + +Press ENTER before the timeout to accept the new configuration + +Changes will revert in 120 seconds +... +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/index.md b/docs/how-to-guides/manage-instances/index.md new file mode 100644 index 0000000000..4fe658cce5 --- /dev/null +++ b/docs/how-to-guides/manage-instances/index.md @@ -0,0 +1,31 @@ +# Manage-Instances +The following guides provide step-by-step instructions on how to manage Multipass instances. + +Multipass allows you to create Ubuntu instances with a single command. As your needs grow, you can modify and customise instances as well as use and create blueprints for customised instances: + +- [Create an instance](/how-to-guides/manage-instances/create-an-instance) +- [Modify an instance](/how-to-guides/manage-instances/modify-an-instance) +- [Use an instance](/how-to-guides/manage-instances/use-an-instance) +- [Use the primary instance](/how-to-guides/manage-instances/use-the-primary-instance) +- [Use instance command aliases](/how-to-guides/manage-instances/use-instance-command-aliases) +- [Share data with an instance](/how-to-guides/manage-instances/share-data-with-an-instance) +- [Remove an instance](/how-to-guides/manage-instances/remove-an-instance) +- [Add a network to an existing instance](/how-to-guides/manage-instances/add-a-network-to-an-existing-instance) +- [Configure static IPs](/how-to-guides/manage-instances/configure-static-ips) +- [Use a blueprint](/how-to-guides/manage-instances/use-a-blueprint) +- [Use the Docker blueprint](/how-to-guides/manage-instances/use-the-docker-blueprint) +- [Run a Docker container in Multipass](/how-to-guides/manage-instances/run-a-docker-container-in-multipass) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + + +```{toctree} +:hidden: +:titlesonly: +:maxdepth: 2 +:glob: + +* +*/index diff --git a/docs/how-to-guides/manage-instances/modify-an-instance.md b/docs/how-to-guides/manage-instances/modify-an-instance.md new file mode 100644 index 0000000000..7f97017411 --- /dev/null +++ b/docs/how-to-guides/manage-instances/modify-an-instance.md @@ -0,0 +1,118 @@ +# Modify an instance +> See also: [Instance](/explanation/instance), [`launch`](/reference/command-line-interface/launch), [`set`](/reference/command-line-interface/set), [Settings](/reference/settings/settings) + +This document shows further ways to customize an instance outside of the [`launch`](/reference/command-line-interface/launch) command using the Multipass [settings](/reference/settings/settings). + +## Set the CPUs , RAM or disk space of an instance + +> See also: [`local..cpus`](/reference/settings/local-instance-name-cpus), [`local..disk)`](/reference/settings/local-instance-name-disk), [`local..memory`](/reference/settings/local-instance-name-memory) + +You can set instance properties at `launch` time, but you can also update some of them after the instance has been created. Specifically, an instance’s memory, disk space, and the number of its CPUs are exposed via daemon settings: `local..(cpus|disk|memory)`. + +To modify one of this properties, first stop the instance and then issue the [`set`](/reference/command-line-interface/set) command. For example: + +```plain +multipass stop handsome-ling +multipass set local.handsome-ling.cpus=4 +multipass set local.handsome-ling.disk=60G +multipass set local.handsome-ling.memory=7G +``` + +[note type="information"] +The disk size can only be increased. +``` + +```{caution} +When increasing the disk size of an instance, the partition may not expand automatically to use the new available space. This usually happens if the partition was already full when trying to increase the disk size. + +In such cases, you need to expand the partition manually. To do so, `shell` into the instance and run the following command: + +```plain +sudo parted /dev/sda resizepart 1 100% +``` + +The system will guide you through the configuration steps: + +
+Warning: Not all of the space available to /dev/sda appears to be used, 
+you can fix the GPT to use all of the space (an extra 4194304 blocks) 
+or continue with the current setting.
+Fix/Ignore? fix
+Partition number? 1
+Warning: Partition /dev/sda1 is being used. 
+Are you sure you want to continue? Yes/No? yes
+
+ +When done, run `sudo resize2fs /dev/sda1`. +``` + +You can view these properties using the `get` command, without the need to stop instances. For example, `multipass get local.handsome-ling.cpus` returns the configured number of CPUs, which in our example is "4". + +[note type="information"] +You can only update the properties of `Stopped`, non-deleted instances. If you try to update an instance that is in `Running`, `Suspended`, or `Deleted` status you'll incur an error. + +On the other hand, it's always possible to fetch properties for all instances. Use `multipass get --keys` to obtain their settings keys. +``` + +[note type="information"] +Modifying instance settings is not supported when using the Hyperkit driver, which has been deprecated in favor of QEMU. The QEMU and VirtualBox drivers on Intel-based macOS hosts do support instance modification. +``` + +## Set the status of an instance to primary + +> See also: [client.primary-name](/reference/settings/client-primary-name) + +This section demonstrates how to set the status of an instance to primary. This is convenient because it makes this instance the default argument for several commands, such as `shell` , `start` , `stop` , `restart` and `suspend`, and also automatically mounts your $HOME directory into the instance. + +To grant a regular instance the primary status, assign its name to the `client.primary-name`: + +```plain +multipass set client.primary-name= +``` + +This setting allows transferring primary status among instances. The primary instance's name can be configured independently of whether instances with the old and new names exist. If they do, they lose and gain primary status accordingly. + +This provides a means of (de)selecting an existing instance as primary. + +### Example + +Assign the primary status to an instance called "first": + +``` +multipass set client.primary-name=first +``` + +This instance is picked up automatically by `multipass start`. When you run this command, the primary instance also automatically mounts the user's home directory into a directory called `Home`: + +``` +... +Launched: first +Mounted '/home/ubuntu' into 'first:Home' +``` + +Run `multipass stop` to stop the primary instance, and then launch another instance named "second": + +``` +multipass launch --name second +``` + +Now, change the primary instance to the existing "second" instance: + +``` +multipass set client.primary-name=second +``` + +From now on, the "second" instance will be used as the *primary* instance, so for example it will be used by default when you run the command `multipass suspend`. + +When listing instances, the primary one is displayed first. For example, if you run `multipass list` now, you'll see: + +``` +Name State IPv4 Image +second Suspended -- Ubuntu 18.04 LTS +first Stopped -- Ubuntu 18.04 LTS +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/remove-an-instance.md b/docs/how-to-guides/manage-instances/remove-an-instance.md new file mode 100644 index 0000000000..330882fc64 --- /dev/null +++ b/docs/how-to-guides/manage-instances/remove-an-instance.md @@ -0,0 +1,66 @@ +# Remove an instance +> See also: [Instance](/explanation/instance) + +This guide demonstrates how to remove an instance, either temporarily or permanently. + +## Move an instance to the recycle bin + +> See also: [`delete`](/reference/command-line-interface/launch), [`recover`](/reference/command-line-interface/recover) + +To mark an instance as deleted, run: + +```plain +multipass delete keen-yak +``` + +Now, if you run `multipass list` to list the instances, you will see that it is actually just marked for deletion (or to put it in other words, moved to the recycle bin): + +```plain +Name State IPv4 Release +keen-yak DELETED -- Not Available +``` + +You can move all instances to the recycle bin at once using the `--all` option: + +```plain +multipass delete --all +``` + +Instances that have been marked as deleted can later be recovered; for example: + +```plain +multipass recover keen-yak +``` + +If you try `multipass list` again, you'll see that the instance is no longer marked for deletion: + +```plain +Name State IPv4 Release +keen-yak STOPPED -- Ubuntu 18.04 LTS +``` + +## Remove an instance permanently + +> See also: [`delete`](/reference/command-line-interface/launch), [`purge`](/reference/command-line-interface/purge) + +If you want to get rid of all instances in `Deleted` status for good, you can purge them: + +```plain +multipass delete keen-yak +multipass purge +``` + +```{caution} +The `purge` command does not take an argument. It will permanently remove all instances marked as `Deleted`. +``` + +You can also use the `--purge` option to permanently delete an instance in a single command; for example: + +```plain +multipass delete --purge keen-yak +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/run-a-docker-container-in-multipass.md b/docs/how-to-guides/manage-instances/run-a-docker-container-in-multipass.md new file mode 100644 index 0000000000..25d95d349c --- /dev/null +++ b/docs/how-to-guides/manage-instances/run-a-docker-container-in-multipass.md @@ -0,0 +1,143 @@ +# Run a Docker container in Multipass + + + + +## Overview + +Multipass has a Docker blueprint that gives its users access to out-of-the-box Docker on any platform. This new blueprint makes it easy to develop and test Docker containers locally on macOS, Windows, or Linux. + +In this tutorial, you will see how to get started with the Docker blueprint by creating a blog in a Docker container in Multipass. + +### What you’ll learn + +- How to use Docker on macOS or Windows with Multipass + +- How to alias the `docker` command to your host command line + +- How to use [Portainer](https://www.portainer.io/) to launch a Docker container in [Multipass](http://multipass.run) + +### What you’ll need + +- Any computer with an internet connection + +## Install Multipass + +Duration: 3 minutes + +Let's start by installing Multipass on your machine, following the steps in [How to install Multipass](/how-to-guides/install-multipass). + +![|720x643](https://assets.ubuntu.com/v1/25ca03d0-mp-docker.png) + +## Launch a Docker VM + +Duration: 1 minute + +Now that Multipass is installed, you can create a VM running Docker very simply. Open up a terminal and type + +```plain +multipass launch docker +``` + +This command will create a virtual machine running the latest version of Ubuntu, with Docker and Portainer installed. You can now use Docker already! Try the command below to see for yourself! + +```plain +multipass exec docker docker` +``` + +![|720x540](https://assets.ubuntu.com/v1/29e87039-mp-docker-2.png) + +## Alias of the Docker commands + +Duration: 1 minute + +The Docker blueprint creates automatically two aliases, that is, two commands which can be run from the host to use commands in the instance as if they were in the host. In particular, the host `docker` command executes `docker` in the instance, and the host `docker-compose` command executes `docker-compose` in the instance. + +In order for these to work, you just need to add them to the path so that you can use them directly from your command line. If this was not done before, launching the Docker blueprint will return instructions showing how to add the aliases to your path. Simply copy and paste the command shown. It will likely be of this form: + +```plain +PATH="$PATH:/home//snap/multipass/common/bin" +``` + + + +Run the command: + +```plain +multipass launch docker +``` + +Sample output: + +```plain +You'll need to add this to your shell configuration (.bashrc, .zshrc or so) for +aliases to work without prefixing with `multipass`: + +PATH="$PATH:/home/nhart/snap/multipass/common/bin" +``` + +You can now use `docker` straight from the command line. To try it out, run + +```plain +docker run hello-world +``` + +## Using Portainer + +Duration: 5 minutes + +Let's now go one step further, with Portainer. The Docker blueprint comes with Portainer installed, which gives an easy-to-use graphical interface for managing your Docker containers. To access Portainer, you will first need its IP address. The following command will show the IP addresses associated with the Ddocker VM you created in the previous steps: + +```plain +multipass list +``` + +![|720x188](https://assets.ubuntu.com/v1/1e998c4e-mp-docker-4.png) + +There should be two IP addresses listed, one for the Docker instance, the other for Portainer. The Portainer IP should start with a 10. + +In a web browser, enter the Portainer IP address from the previous step followed by the Portainer port, 9000, like this: “:9000”. Set up a username and password at the prompt, then select the option for managing a *local* Docker environment and click *connect*. + +![|720x596](https://assets.ubuntu.com/v1/0f980233-mp-docker-5.png) + +Click on the newly created “Local” environment to manage the Docker instance on your local VM. + +![|720x459](https://assets.ubuntu.com/v1/3a7af624-mp-docker-6.png) + +## Launching a container + +Duration: 5 minutes + +For this tutorial, you will be creating a blog using the Ghost template in Portainer. Portainer has many other app templates if you are looking for more ideas. If you want more selection, you can launch containers from the Docker hub from Portainer or from the command line. + +Inside Portainer, click on **App Templates** in the left toolbar, and scroll down to the **Ghost** template. + +![|720x461](https://assets.ubuntu.com/v1/b80ef240-mp-docker-7.png) + +Now, you can configure and deploy the template. Enter a name and click deploy. The **bridge** network is the default and correct option. + +![|720x541](https://assets.ubuntu.com/v1/1ade4cfc-mp-docker-8.png) + +On the **Containers** page, you should now see two containers running. One containing Ghost, and the other containing Portainer itself. + +![|720x373](https://assets.ubuntu.com/v1/0e720c25-mp-docker-9.png) + +You can now access your Ghost blog by going to the published port indicated in the Containers page, i.e., **\:\**. + +![|720x603](https://assets.ubuntu.com/v1/357843ef-mp-docker-10.png) + +There it is, your blog running within a Docker container inside Multipass! + +For next steps, try out Portainer’s other App Templates (Step 5), or check out [Docker Hub](https://hub.docker.com/search?type=image) for more containers to try. If you want to try out container orchestration, [Microk8s](https://microk8s.io/) or Multipass’ [Minikube](https://minikube.sigs.k8s.io/docs/) blueprint are great places to start. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/share-data-with-an-instance.md b/docs/how-to-guides/manage-instances/share-data-with-an-instance.md new file mode 100644 index 0000000000..42906c6297 --- /dev/null +++ b/docs/how-to-guides/manage-instances/share-data-with-an-instance.md @@ -0,0 +1,111 @@ +# Share data with an instance +> See also: [Instance](/explanation/instance), [Mount](/explanation/mount), [ID mapping](/explanation/id-mapping), [`launch`](/reference/command-line-interface/launch), [`mount`](/reference/command-line-interface/mount), [`umount`](/reference/command-line-interface/umount), [`transfer`](/reference/command-line-interface/transfer) + +This guide explains how to share data between your host and an instance. There are two ways to accomplish this: +* the `mount` command, that maps a local folder to a new or existing folder in the instance's filesystem +* the `transfer` command, that copies files to and from an instance + +## Using `mount` + +You can use the [`multipass mount`](/reference/command-line-interface/mount) command to share data between your host and an instance, by making specific folders in your host's filesystem available in your instance's filesystem, with read and write permissions. Mounted paths are persistent, meaning that they will remain available until they are explicitly unmounted. + +The basic syntax of the `mount` command is: + +```plain +multipass mount +``` + +For example, to map your local home directory on a Linux system (identified as $HOME) into the `keen-yak` instance, run this command: + +```plain +multipass mount $HOME keen-yak +``` + +You can check the result running `multipass info keen-yak`: + +```plain +… +Mounts: /home/michal => /home/michal +``` + +From this point the local home directory `/home/michal` will be available inside the instance. + +If you want to mount a local directory to a different path in your instance, you can specify the target path as follows: + +```plain +multipass mount $HOME keen-yak:/some/path +``` + +```{caution} +If the `/some/path` directory already exists in the instance's filesystem, its contents will be temporarily hidden ("overlaid") by the mounted directory, but not overwritten. The original folder remains intact and will be revealed if you unmount. + +For this reason, it is not possible to mount an external folder path over the instance's $HOME directory, because it also contains the SSH keys required to access the instance: by hiding them, you would no longer be able to shell into the instance. +``` + +You can also define mounts when you create an instance, using the [`multipass launch`](/reference/command-line-interface/launch) command with the `--mount` option: + +```plain +multipass launch --mount /local/path:/instance/path +``` + +### Unmounting shared directories + +To unmount previously mounted paths, use the [`multipass umount`](/reference/command-line-interface/umount) command. + +You can specify the folder path to unmount: + +```plain +multipass umount keen-yak:/home/michal +``` + +or, if you don't specify any paths, unmount all shared folders at once: + +```plain +multipass umount keen-yak +``` + +## Using `transfer` + +You can also use the [`multipass transfer`](/reference/command-line-interface/transfer) command to copy files from your local filesystem to the instance's filesystem, and vice versa. + +To indicate that a file is inside an instance, prefix its path with `:`. + +For example, to copy the `crontab` and `fstab` files from the `/etc` directory on the `keen-yak` instance to the `/home/michal` folder in the host's filesystem: + +```plain +multipass transfer keen-yak:/etc/crontab keen-yak:/etc/fstab /home/michal +``` + +The files will be copied with the correct user mapping, as you'll see running the `ls -l /home/michal` command: + +```plain +… +-rw-r--r-- 1 michal michal 722 Oct 18 12:13 /home/michal/crontab +-rw-r--r-- 1 michal michal 82 Oct 18 12:13 /home/michal/fstab +… +``` + +The other way around, if you want to copy these files from your local filesystem into the instance, run the command: + +```plain +multipass transfer /etc/crontab /etc/fstab keen-yak:/home/michal +``` + +In this case, the output of the `ls -l /home/michal` command on the instance will be: +```plain +… +-rw-rw-r-- 1 ubuntu ubuntu 722 Oct 18 12:14 crontab +-rw-rw-r-- 1 ubuntu ubuntu 82 Oct 18 12:14 fstab +… +``` + +See also [ID mapping](/explanation/id-mapping) for more information on how the mount command maps user and group IDs between the host and the instance. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @saviq, @nhart, @andreitoterman, @ricab, @gzanchi + diff --git a/docs/how-to-guides/manage-instances/use-a-blueprint.md b/docs/how-to-guides/manage-instances/use-a-blueprint.md new file mode 100644 index 0000000000..4828236991 --- /dev/null +++ b/docs/how-to-guides/manage-instances/use-a-blueprint.md @@ -0,0 +1,35 @@ +# Use a blueprint +> See also: [Blueprint](/explanation/blueprint) + +Blueprints provide a shortcut to initialising Multipass instances for a variety of applications. + +To see what blueprints are available, run + +```plain +multipass find --only-blueprints +``` + +> See more: [`multipass find`](/reference/command-line-interface/find) + +To use a blueprint run: + +```plain +multipass launch +``` + +Launching a blueprint can take the same arguments as launching any other type of instance. If no further arguments are specified, the instance will launch with the defaults defined in the blueprint. Here’s an example of creating an instance from the Docker blueprint with a few more parameters specified: + +```plain +multipass launch docker --name docker-dev --cpus 4 --memory 8G --disk 50G --bridged +``` + +This command will create an instance based on the Docker blueprint, with 4 CPU cores, 8GB of RAM, 50 GB of disk space, and connect that instance to the (predefined) bridged network. + +Blueprints also provide a way of exchanging files between the host and the instance. For this, a folder named `multipass/` is created in the user's home directory on the host and mounted in `` in the user's home directory on the instance. + +> See more: [`multipass launch`](/reference/command-line-interface/launch) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/use-an-instance.md b/docs/how-to-guides/manage-instances/use-an-instance.md new file mode 100644 index 0000000000..0a85a2cd02 --- /dev/null +++ b/docs/how-to-guides/manage-instances/use-an-instance.md @@ -0,0 +1,157 @@ +# Use an instance +> See also: [Instance](/explanation/instance) + +This document demonstrates various ways to use an instance. + +## Open a shell prompt inside an instance + +> See also: [`shell`](/reference/command-line-interface/shell) + +To open a shell prompt on an existing instance (e.g. `loving-duck`), run the command `multipass shell loving-duck`. The output will be similar to the following: + +```plain +Welcome to Ubuntu 20.04.4 LTS (GNU/Linux 5.4.0-109-generic x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + System information as of Tue May 31 14:26:40 -03 2022 + + System load: 0.0 Processes: 113 + Usage of /: 28.8% of 4.67GB Users logged in: 0 + Memory usage: 21% IPv4 address for ens3: 10.49.93.241 + Swap usage: 0% + + +1 update can be applied immediately. +To see these additional updates run: apt list --upgradable + + +The list of available updates is more than a week old. +To check for new updates run: sudo apt update + +To run a command as administrator (user "root"), use "sudo ". +See "man sudo_root" for details. + +ubuntu@loving-duck:~$ +``` + +If the instance `loving-duck` is `Stopped` or `Suspended`, it will be started automatically. + +If no argument is given to the `shell` command, Multipass will open a shell prompt on the primary instance (and also create it, if it doesn't exist). + +As shown in the example above, an Ubuntu prompt is displayed as a result of the `shell` command, where you can run commands inside the instance. + +To end the session, use `logout`, `exit`, or the `Ctrl-D` shortcut. + +[note type="information"] +This is also available on the GUI. +``` + +## Run a command inside an instance + +> See also: [`exec`](/reference/command-line-interface/exec) + +To run a single command inside an instance, you don't need to open a shell. The command can be directly called from the host using `multipass exec`. For example, the command `multipass exec loving-duck -- pwd` returns: + +```plain +/home/ubuntu +``` + +In the example, `/home/ubuntu` is the output of invoking the `pwd` command on the `loving-duck` instance. + +## Start an instance + +> See also: [`start`](/reference/command-line-interface/start) + +An existing instance that is in `Stopped` or `Suspended` status can be started with the `multipass start` command; for example: + +```plain +multipass start loving-duck +``` + +You can start multiple instances at once, specifying the instance names in the command line: + +```plain +multipass start loving-duck devoted-lionfish sensible-shark +``` + +To start all existing instances at once, use the `--all` option: + +```plain +multipass start --all +``` + +If no options are specified, the `multipass start` command starts the primary instance, creating it if needed. + +[note type="information"] +This is also available on the GUI. +``` + +## Suspend an instance + +> See also: [`suspend`](/reference/command-line-interface/suspend) + +An instance can be suspended with the command: + +```plain +multipass suspend loving-duck +``` + +You can suspend multiple instances at once, specifying the instance names in the command line: + +```plain +multipass suspend loving-duck devoted-lionfish sensible-shark +``` + +To suspend all running instances at once, use the `--all` option: + +```plain +multipass suspend --all +``` + +If no options are specified, the `multipass suspend` command suspends the primary instance, if it exists and is running. + +## Stop an instance + +> See also: [`stop`](/reference/command-line-interface/stop) + +A running, not suspended instance is stopped with the command: + +```plain +multipass stop loving-duck +``` + +You can stop multiple instances at once, specifying the instance names in the command line: + +```plain +multipass stop loving-duck devoted-lionfish sensible-shark +``` + +To stop all running instances at once, use the `--all` option: + +```plain +$ multipass stop --all +``` + +If no options are specified, the `multipass stop` command stops the primary instance, if it exists and is running. + +### Stop an instance forcefully + +If the `multipass stop` command doesn’t work, you can use the `--force` argument to force the instance to shut down immediately. This is particularly useful when the virtual machine is in a non-responsive, unknown or suspended state. + +```plain +multipass stop --force +``` + +```{caution} The `stop --force` command is analogous to unplugging the power cord from a physical machine – it immediately halts all computing activities. This may be necessary under certain circumstances but can potentially lead to data loss or corruption. ``` + +[note=information] This command is also available on the Multipass GUI. ``` + + + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/use-instance-command-aliases.md b/docs/how-to-guides/manage-instances/use-instance-command-aliases.md new file mode 100644 index 0000000000..dd98548c64 --- /dev/null +++ b/docs/how-to-guides/manage-instances/use-instance-command-aliases.md @@ -0,0 +1,227 @@ +# Use instance command aliases +> See also: [Alias](/explanation/alias), [How to use command aliases](/how-to-guides/manage-instances/use-instance-command-aliases), [Instance](/explanation/instance). + +This guide demonstrates how to create, list, run and remove aliases for commands running inside an instance. + +## Create an alias + +> See also: [`alias`](/reference/command-line-interface/alias) + +To create an alias that runs a command on a given instance, use the command [`multipass alias`](/reference/command-line-interface/alias). The code below uses this command to create an alias `lscc` that will run the command `ls` inside an instance `crazy-cat`: + +```plain +multipass alias crazy-cat:ls lscc +``` + +After running this command, the alias `lscc` is defined as running the command `ls` on the instance `crazy-cat`. If the alias name `lscc` is omitted, the alias name defaults to the name of the command to run (`ls` in this case). + +### Working directory mapping + +By default, if the host folder on which you are running an alias is mounted on the instance, the working directory on the instance is changed to the mounted directory. To avoid this behaviour, use the option `--no-map-working-directory` when defining the alias; for example: + +```plain +multipass alias crazy-cat:pwd pwdcc --no-map-working-directory +``` + +### Alias contexts + +> See also: [`prefer`](/reference/command-line-interface/prefer) + +Contexts are sets of aliases. While one can safely work with one context, named `default`, contexts can be useful in some scenarios; for example, to define aliases with the same name in different instances. + +You can switch to using another context with `multipass prefer secondary`. Then, defining an alias in the new context is done in the usual way. The name of the alias can coincide with an already defined one. For example, `multipass alias cozy-canary:ls lscc`. + +## List the existing aliases + +> See also: [`aliases`](/reference/command-line-interface/aliases) + +To see the list of aliases defined so far, use the `multipass aliases` command. + +The output will be similar to the following: + +```plain +Alias Instance Command Context Working directory +lscc crazy-cat ls default map +pwdcc crazy-cat pwd default default +lscc cozy-canary ls secondary* map +``` + +The current context is marked with an asterisk. + +The column `Working directory` tells us on which directory of the host the alias will be run. The value `default` means that the alias will be run in the instance default working directory (normally, `/home/ubuntu`). The value `map` means that, in case the host directory from which the user calls the alias is mounted on the instance, the alias will be run on the mounted directory on the instance. The value will be `default` only if the `--no-map-working-directory` argument is present at alias creation. + +## Run an alias + +There are two ways to run an alias: +* `multipass ` +* `` + +### `multipass ` + +The first way of running an alias is invoking it with `multipass `, for example: + +```plain +multipass lscc +``` + +This command opens a shell into the instance `cozy-canary`, runs `ls` and returns to the host command line, as if it was an `exec` command. Since we have defined two aliases with the same name, `lscc`, the one in the current context will be run. + +If you want to run an alias outside the current context, you can use a fully-qualified alias name: + +```plain +multipass default.lscc +``` + +Arguments are also supported, provided you separate any options with `--`: + +```plain +multipass lscc -- -l +``` + +or: + +```plain +multipass default.lscc -- -l +``` + +### `` + +The second way of running an alias is a two-step process: + +1. Add the Multipass alias script folder to the system path. +2. Run the alias. + +#### Add the Multipass alias script folder to the system path + +The instructions to add the Multipass alias script folder to the system path are displayed the first time you create an alias, and vary for each platform. For instance, when you run the command: + +```plain +multipass alias crazy-cat:ls lscc +``` + +the following output is displayed: + +```plain +You'll need to add this to your shell configuration (.bashrc, .zshrc or so) for +aliases to work without prefixing with `multipass`: + +PATH="$PATH:/home/user/snap/multipass/common/bin" +``` + +[tabs] + +[tab version="Linux"] + +On Linux, you'll have to edit the shell configuration file. In most Linux distributions, the shell used by default is `bash`. You can configure this option by editing the file `.bashrc` in the user's home directory using a text editor; for example: + +```plain +nano ~/.bashrc +``` + +You can modify the path by appending a line to the `.bashrc` file, such as: + +```plain +export PATH="$PATH:/home/user/snap/multipass/common/bin" +``` + +[note type="information"] +Remember to replace the correct folder, as indicated in the output of the Multipass command above, and to restart the shell when done. + +If your shell is `zsh` and not `bash`, the file to modify is `.zshrc` instead of `.bashrc`. The procedure is the same. +``` + +[/tab] + +[tab version="macOS"] + +On macOS, you'll have to edit the shell configuration file. The shell used by default is `zsh`. You can configure this option by editing the file `.zshrc` in the user's home directory using a text editor. + +You can modify the path by appending a line to the `.zshrc` file, such as: + + +```plain +export PATH="$PATH:/Users//Library/Application Support/multipass/bin" +``` + +[note type="information"] +Remember to replace the correct folder, as indicated in the output of the Multipass command above, and to restart the shell when done. +``` + +[/tab] + +[tab version="Windows"] + +On Windows, to make the change permanent, use PowerShell to store the old system path, add the alias folder to it, and store the new path: + +```powershell +$old_path = (Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH).path +$new_path = “$old_path;C:\Users\\AppData\Local\Multipass\bin” +Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value $new_path +``` + +Don't forget to restart your terminal. The folder is now permanently added to your path, and Multipass can now run aliases just invoking their name. + +[/tab] + +[/tabs] + +#### Run the alias + +Once you've added the alias folder to the system path, you can run it directly from the command line, without the need to also mention `multipass`; for example: + +```plain +lscc +``` + +or: + +```plain +default.lscc +``` + +Since the path has been added to the system path, this command is equivalent to `multipass lscc`. Arguments are also supported, without the need for `--`: + +```plain +lscc -l +``` + +## Remove an alias + +> See also: [`unalias`](/reference/command-line-interface/unalias) + +Finally, to remove the alias `lscc`, run the following command: + +```plain +multipass unalias lscc +``` + +or: + +```plain +multipass unalias default.lscc +``` + +The `unalias` command accepts many arguments, specifying more than one alias to remove. For example, you can remove both aliases `lscc` and `pwdcc` at once: + +```plain +multipass unalias lscc pwdcc +``` + +You can also use the `--all` option to remove all the defined aliases in the current context at once: + +```plain +multipass unalias --all +``` + +[note type="information] +Aliases are also removed when the instance for which they were defined is deleted and purged. This means that `multipass delete crazy-cat --purge` will also remove the aliases `lscc` and `pwdcc`. +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @luisp , @saviq , @tmihoc , @andreitoterman , @itecompro , @ricab , @gzanchi , @sharder996 + diff --git a/docs/how-to-guides/manage-instances/use-the-docker-blueprint.md b/docs/how-to-guides/manage-instances/use-the-docker-blueprint.md new file mode 100644 index 0000000000..5745160bfa --- /dev/null +++ b/docs/how-to-guides/manage-instances/use-the-docker-blueprint.md @@ -0,0 +1,27 @@ +# Use the Docker blueprint +The Docker blueprint gives Multipass users an easy way to create Ubuntu instances with Docker installed. It is based on the latest LTS release of Ubuntu, and includes docker engine and [Portainer](https://www.portainer.io/). The Docker blueprint automatically aliases the `docker` and `docker-compose` commands to your host, and creates a workspace that is shared between the host and the instance. + +To use the Docker blueprint, run `multipass launch docker`, which will launch an instance with default parameters. + +Next, follow the instructions in the output to add the aliased command to your path, it should look something like this: + +```plain +You'll need to add this to your shell configuration (.bashrc, .zshrc or so) for + +aliases to work without prefixing with `multipass`: + +PATH="$PATH:/home/user/snap/multipass/common/bin" +``` + +[note type=tip] +Running `which docker` from your host command line should confirm that you are running Docker inside Multipass. +``` + +To access Portainer, run `multipass ls` and copy the IP address of the multipass instance (the first in the list), then enter it into your browser followed by a colon and Portainer’s port number, 9000 (something like this: 10.21.145.191:9000). This gives you Portainer's web interface for visually managing your containers. + +You can mount files into this instance as with any Multipass instance, but the default shared workspace is an easy way to edit your `dockerfiles` and `docker-compose.yaml` files from your host. With working directory mapping, you can run the `docker-compose` command from your host inside the shared directory, and have it run within that same directory in your Multipass instance. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/manage-instances/use-the-primary-instance.md b/docs/how-to-guides/manage-instances/use-the-primary-instance.md new file mode 100644 index 0000000000..3144736184 --- /dev/null +++ b/docs/how-to-guides/manage-instances/use-the-primary-instance.md @@ -0,0 +1,83 @@ +# Use the primary instance +> See also: [Instance](/explanation/instance), [client.primary-name](/reference/settings/client-primary-name), [`shell`](/reference/command-line-interface/shell), [`mount`](/reference/command-line-interface/mount) + +Multipass offers a quick way to access an Ubuntu instance via a simple `multipass shell` command. This is achieved via the so-called [primary instance](/t/28469#primary-instance) that is also automatically created (if it doesn't exist) when the user runs the [`multipass start`](/reference/command-line-interface/start) or [`multipass shell`](/reference/command-line-interface/shell) commands without any arguments. + +When automatically created, the primary instance gets the same properties as if [`launch`](/reference/command-line-interface/launch) was used with no arguments, except for the name (`primary` by default). In particular, this means that the instance will use the latest Ubuntu LTS image and will have the default CPU, disk and memory configuration. + +You can also launch the primary instance with additional parameters, as you would do for any other instance. This provides one way to fine-tune its properties (e.g. `multipass launch --name primary --cpus 4 lts`). Alternatively, you can set another instance as primary, as explained in [Changing the primary instance](#changing-the-primary-instance) below. + +There can be only one primary instance at any moment. If it exists, it is always listed first in the output of `list` and `info`. + +## Steering the primary instance + +The primary instance can also be controlled from the [tray icon](/t/28484#tray-icon) menu. + +In the command line, it is used as the default when no instance name is specified in the `shell`, `start`, `stop`, `restart` and `suspend` commands. When issuing one of these commands with no positional arguments, the primary instance is targeted. Its name can still be given explicitly wherever an instance name is expected (e.g. `multipass start primary`). + +## Automatic home mount + +When launching the primary instance, whether implicitly or explicitly, Multipass automatically mounts the user's home inside it, in the folder `Home`. As with any other mount, you can unmount it with `multipass umount`. For instance, `multipass umount primary` will unmount all mounts made by Multipass inside `primary`, including the auto-mounted `Home`. + +[note type=information] +On Windows mounts are disabled by default for security reasons. See [`multipass set`](/reference/command-line-interface/set) and [local.privileged-mounts](/reference/settings/local-privileged-mounts) for information on how to enable them if needed. +``` + +## Changing the primary instance + +The primary instance is identified as such by its name. The name that designates an instance as the primary one is determined by a configuration setting with the key `client.primary-name`. In other words, while `primary` is the default name of the primary instance, you can change it with `multipass set client.primary-name=`. + +This setting allows transferring primary status among instances. You can configure the primary name independently of whether instances with the old and new names exist. If they do, they lose and gain primary status accordingly. + +This provides a means of (de)selecting an existing instance as primary. For example, after `multipass set client.primary-name=first`, the primary instance would be called `first`. A subsequent `multipass start` would start `first` if it existed, and launch it otherwise. + +## Example + +Here is a long-form example of how Multipass handles the primary instance. + +Set the name of the primary instance and start it: + +```plain +multipass set client.primary-name=first +multipass start +``` + +Sample output: + +```plain +Launched: first +Mounted '/home/ubuntu' into 'first:Home' +``` + +Now, stop the primary and launch another instance: + +```plain +multipass stop +multipass launch eoan +``` + +Sample output: + +```plain +Launched: calm-chimaera +``` + +Change the `client.primary-name` setting to the newly launched instance, and review the list of existing instances: + +```plain +multipass set client.primary-name=calm-chimaera +multipass list +``` + +Sample output: + +```plain +Name State IPv4 Image +calm-chimaera Running 10.122.139.63 Ubuntu 19.04 LTS +first Stopped -- Ubuntu 18.04 LTS +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/troubleshoot/access-logs.md b/docs/how-to-guides/troubleshoot/access-logs.md new file mode 100644 index 0000000000..0603cf89d9 --- /dev/null +++ b/docs/how-to-guides/troubleshoot/access-logs.md @@ -0,0 +1,47 @@ +# Access logs +Logs are our first go-to when something goes wrong. Multipass is comprised of a daemon process (service) and the [CLI](/reference/command-line-interface/command-line-interface) and [GUI](/reference/gui-client) clients, each of them reporting on their own health. + +The `multipass` command accepts the `--verbose` option (`-v` for short), which can be repeated to go from the default (*error*) level through *warning*, *info*, *debug* up to *trace*. + +We use the underlying platform's logging facilities to ensure you get the familiar behaviour wherever you are. + +[tabs] + +[tab version="Linux"] + +On Linux, [`systemd-journald`](https://www.freedesktop.org/software/systemd/man/systemd-journald.service.html) is used, integrating with the de-facto standard for this on modern Linux systems. + +To access the daemon (and its child processes') logs: + +```console +journalctl --unit 'snap.multipass*' +``` + +The Multipass GUI produces its own logs, that can be found under `~/snap/multipass/current/data/multipass_gui/multipass_gui.log` + +[/tab] + +[tab version="macOS"] + +On macOS, log files are stored in `/Library/Logs/Multipass`, where `multipassd.log` has the daemon messages. You will need `sudo` to access it. + +The Multipass GUI produces its own logs, that can be found under `~/Library/Application\ Support/com.canonical.multipassGui/multipass_gui.log` + +[/tab] + +[tab version="Windows"] + +On Windows, the Event system is used and Event Viewer lets you access them. Our logs are currently under "Windows Logs/Application", where you can filter by "Multipass" Event source. You can then export the selected events to a file. + +Logs from the installation and uninstall process can be found under `%APPDATA%\Local\Temp`. Sort the contents of the directory by "Date Modified" to bring the newest files to the top. The name of the file containing the logs follows the pattern `MSI[0-9a-z].LOG`. + +The Multipass GUI produces its own logs, that can be found under `%APPDATA%\com.canonical\Multipass GUI\multipass_gui.log` + +[/tab] + +[/tabs] + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/how-to-guides/troubleshoot/index.md b/docs/how-to-guides/troubleshoot/index.md new file mode 100644 index 0000000000..fdf20326ac --- /dev/null +++ b/docs/how-to-guides/troubleshoot/index.md @@ -0,0 +1,21 @@ +# Troubleshoot +The following guides provide step-by-step instructions on how to troubleshoot issues with your Multipass installation, beginning by inspecting the logs. + +- [Access logs](/how-to-guides/troubleshoot/access-logs) +- [Mount an encrypted home folder](/how-to-guides/troubleshoot/mount-an-encrypted-home-folder) +- [Troubleshoot launch/start issues](/how-to-guides/troubleshoot/troubleshoot-launch-start-issues) +- [Troubleshoot networking](/how-to-guides/troubleshoot/troubleshoot-networking) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + + +```{toctree} +:hidden: +:titlesonly: +:maxdepth: 2 +:glob: + +* +*/index diff --git a/docs/how-to-guides/troubleshoot/mount-an-encrypted-home-folder.md b/docs/how-to-guides/troubleshoot/mount-an-encrypted-home-folder.md new file mode 100644 index 0000000000..cec29270c2 --- /dev/null +++ b/docs/how-to-guides/troubleshoot/mount-an-encrypted-home-folder.md @@ -0,0 +1,26 @@ +# Mount an encrypted home folder + + + +> See also: [`mount`](/reference/command-line-interface/mount), [Instance](/explanation/instance) + +When you create the [primary instance](/t/28469#primary-instance-1) using `multipass start` or `multipass shell` without additional arguments, Multipass automatically mounts your home directory into it. + +On Linux, if your local home folder is encrypted using ` fscrypt`, [snap confinement](https://snapcraft.io/docs/snap-confinement) prevents you from accessing its contents from a Multipass mount due the peculiar directory structure (`/home/.ecryptfs//.Private/`). This also applies to the primary instance, where the home folder is mounted automatically. + +A workaround is mounting the entire `/home` folder into the instance, using the command: + +```plain +multipass mount /home primary +``` + +By doing so, the home folder's contents will be mounted correctly. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @ricab, @gzanchi + diff --git a/docs/how-to-guides/troubleshoot/troubleshoot-launch-start-issues.md b/docs/how-to-guides/troubleshoot/troubleshoot-launch-start-issues.md new file mode 100644 index 0000000000..78a7f02e9f --- /dev/null +++ b/docs/how-to-guides/troubleshoot/troubleshoot-launch-start-issues.md @@ -0,0 +1,289 @@ +# Troubleshoot launch/start issues + + +This topic addresses common issues when launching or starting instances, such as *timeouts or "unknown state" errors*. + +These problems can occur for a few different reasons. Since Multipass relies on instances having an IP address on the default interface to establish an SSH connection, they are often (but not always) linked to IP assignment or connectivity issues. + +The possible reasons that can lead the `launch` or `start` commands to fail are: + +1. When you launch a new instance, it fails to load the required image due to stale network cache. +2. The VM didn't manage to boot properly and didn't get to the point where it requests an IP address. +3. The VM requested an IP address, but didn't obtain one. +4. The VM obtained an IP address, but: + 1. Multipass can't find it. + 2. Multipass finds an IP that doesn't match the one that was assigned to the instance. +5. SSH doesn't function properly in the VM, or Multipass is blocked from accessing it. +6. When you launch a new instance, it times out waiting for initialization to complete. + +## Diagnose your issue + +Follow these steps to diagnose your issue and identify the most likely scenario: + +1. If the `multipass launch` command fails with the message "Downloaded image hash does not match", see: [Stale network cache](#stale-network-cache-6). + +1. [Windows, Hyper-V driver] Inspect the file `C:\WINDOWS\System32\drivers\etc\hosts.ics` and see if there is more than one entry with your instance name in it. If that's the case, see: [Stale internet connection sharing lease](#stale-internet-connection-sharing-lease). + +1. [Linux/macOS, QEMU driver] Inspect the Multipass logs and look for a message mentioning `NIC_RX_FILTER_CHANGED`. This message indicates that the network interface has been initialised. + * If you don't find it, it means that the VM didn't manage to bring up the interface; see: [VM boot failure](#vm-boot-failure-3). + * If the message is present, proceed to check DHCP traffic in the next step. + +1. [Linux/macOS, QEMU driver] Check DHCP traffic from your host to the instance, to find out if there are requests and replies. Adapt and run the following command *right after starting/launching* the instance: + + ``` + sudo tcpdump -i udp port 67 and port 68 + ``` + + You will need to replace `` with `mpqemubr0` on Linux and with `bridge100` on macOS. + + ```{note}Note that, on macOS, `bridge100` is a virtual network interface that only appears when at least a VM is running.``` + + * If you see `NIC_RX_FILTER_CHANGED`, you should also see DHCP requests. If you don't, see [VM boot failure](#vm-boot-failure-3) and please [let us know](https://github.com/canonical/multipass/issues/new/choose). + * If you see a DHCP request, but no reply, it means that the VM is still waiting for an IP address to be assigned; see: [No IP assigned](#no-ip-assigned-4). + * If you see DHCP requests and replies, continue to the next step. + +1. Look for messages regarding SSH in Multipass's logs. The instance may have obtained an IP and/or be properly connected, but still refuse Multipass when it tries to SSH into it. + +1. Look for the message in the CLI or GUI spinner. Once it reads "Waiting for initialization to complete", Multipass willl have succeeded SSH-ing into the instance but remain waiting for cloud-init to finish. + +## Troubleshooting steps + +### VM boot failure + +To find out if something is failing during boot, you'd need to attach to the VM's console/serial and observe the output and try to find out where the VM is getting stuck. Here is how you can do that, depending on the driver: + +- [Linux/macOS, QEMU driver] Relaunch QEMU manually: + 1. Look for the `qemu-system-*` command line corresponding to the failing VM in Multipass logs + 2. copy it to an editor and modify it + 1. remove `-serial chardev:char0 -nographic` + 2. escape any spaces in paths (e.g. `Application Support` should become `Application\ Support`) + 3. Run the edited line in a terminal, with `sudo`. Here is an example: + ``` + /Library/Application\ Support/com.canonical.multipass/bin/qemu-system-aarch64 -machine virt,gic-version=3 -accel hvf -drive file=/Library/Application\ Support/com.canonical.multipass/bin/../Resources/qemu/edk2-aarch64-code.fd,if=pflash,format=raw,readonly=on -cpu host -nic vmnet-shared,model=virtio-net-pci,mac=52:54:00:e2:30:dd -device virtio-scsi-pci,id=scsi0 -drive file=/var/root/Library/Application\ Support/multipassd/qemu/vault/instances/superior-chihuahua/ubuntu-22.04-server-cloudimg-arm64.img,if=none,format=qcow2,discard=unmap,id=hda -device scsi-hd,drive=hda,bus=scsi0.0 -smp 2 -m 4096M -qmp stdio -cdrom /var/root/Library/Application\ Support/multipassd/qemu/vault/instances/superior-chihuahua/cloud-init-config.iso + ``` + This will open a QEMU window where you can see the boot output. You may need to select the correct display output (Serial or VGA) from the QEMU menu. + +- [macOS/Windows, VirtualBox driver] Observe the output in the VirtualBox GUI: + 1. Run the VirtualBox GUI as admin/root: + - [macOS] `sudo VirtualBox` + - [Windows] [Run with `psexec.exe`](...): + 2. Start or launch the instance with `multipass start|launch` + 3. Select and attach to the VM in the VirtualBox GUI and observe the boot output. If it eventually arrives at a login screen, it means that the instance should've started correctly. + +- [Windows, Hyper-V driver] + 1. Open the Hyper-V Manager GUI (look for it in your Start menu) + 2. Start or launch the instance with `multipass start|launch` + 2. Select the VM in Hyper-V manager and click "Connect" on the Actions pane, at the right-hand side. Observe the boot output. + +#### VM image corruption + +Boot failures are often caused by VM image corruption, which can happen when the VM is killed without a proper shutdown. + +Here are some options to attempt recovery: + +- If you took a [snapshot](/explanation/snapshot) before incurring this issue, you could try to restore it. However, snapshots are typically stored layers against an original image file, so they may not be enough. +- **Run [`fsck`](https://manpages.ubuntu.com/manpages/oracular/en/man8/fsck.8.html) in the Serial Console:** + + The `fsck` tool (short for "file system consistency check") is used to scan the file system for errors and attempt repairs. + + **To use it, access the VM’s console as described above and follow these steps:** + + 1. **Access the VM's Console** + + - Use the method appropriate for your driver to access the VM's console, as described in the [VM Boot Failure](#vm-boot-failure) section. + + 2. **Interrupt the Boot Process** + + - As the VM starts booting, interrupt the boot process to access the GRUB menu: + - Press the `Esc` key repeatedly during the VM's startup until the GRUB menu appears. + - On some systems, you might need to hold down the `Shift` key instead. + - The key needs to be pressed at just the right time, after UEFI loading (to avoid getting into the UEFI screen), but before Ubuntu starts booting (to trigger GRUB) + + 3. **Enter Recovery Mode** + + - In the GRUB menu: + - Use the arrow keys to select **Advanced options for Ubuntu** (or your distribution's equivalent) and press `Enter`. + - Select a kernel version with `(recovery mode)` appended and press `Enter`. + + 4. **Run `fsck` from Recovery Menu** + + - Once in the recovery menu: + - Use the arrow keys to highlight **`fsck`** and press `Enter`. + - You will be prompted to remount the filesystem in read/write mode. Select **Yes**. + - The system will run `fsck` and attempt to repair any detected issues. + + 5. **Alternatively, Drop to a Root Shell** + + - If you prefer to run `fsck` manually: + - From the recovery menu, select **`root`** to drop to a root shell prompt. + - At the prompt, run the following commands: + + ```bash + mount -o remount,ro / + fsck -f / + ``` + + - After `fsck` completes, remount the filesystem in read/write mode: + + ```bash + mount -o remount,rw / + ``` + + - Type `exit` to return to the recovery menu. + + 6. **Resume Normal Boot** + + - In the recovery menu, select **`resume`** to continue with the normal boot process. + - The system should now boot normally if `fsck` was able to repair the filesystem. + +- [Linux/macOS] Alternatively, run `fsck` over a [mounted image](#reading-data-from-a-qcow2-image-12) on the host. +- Run `qemu-img check -r` on the image. + * `qemu-img`, shipped with Multipass, can also be used to check and repair disk images. + * See below how to [locate it](#locating-multipass-binaries-draft). + * See [here](#locating-multipass-images-draft) on how to locate images. + * For example: + ``` + /Library/Application\ Support/com.canonical.multipass/bin/qemu-img check -r /var/root/Library/Application\ Support/multipassd/qemu/vault/instances// + ``` +- If none of the above works, you can still try to [mount the image manually]() to recover data. + +### No IP assigned + +Sometimes VMs request an IP address, but don't obtain one. That can happen because of interference from other software, VPNs, network misconfiguration and, firewall settings. + +#### [macOS, QEMU driver] Firewall blocks `bootp` + +The macOS firewall is known to cause `vmnet` to malfunction, because it blocks Apple's own `bootp` from giving out IPs. The effect of this problem on Multipass is tracked in [this issue](https://github.com/canonical/multipass/issues/2387), which we internally call the *dreaded firewall issue*. + +You may be able to work around it by disabling the firewall entirely, or executing + +``` +/usr/libexec/ApplicationFirewall/socketfilterfw --add /usr/libexec/bootpd +/usr/libexec/ApplicationFirewall/socketfilterfw --unblock /usr/libexec/bootpd +``` + +We are aware that this requires administrative privileges, which managed Macs won't have. We unfortunately don't have a better fix for those cases. We continue hoping that Apple will eventually fix the problem which, to the best of our knowledge, affects all products using `vmnet`. Chances of that happening will probably increase if enough people [report it to them](https://developer.apple.com/bug-reporting/). + +> See also: [How to troubleshoot networking](/how-to-guides/troubleshoot/troubleshoot-networking). +> +#### [macOS, QEMU driver] `bootp` not coming up + +The DHCP server should be launched automatically when there is a request, but you can also launch it manually if needed. To do so, run: + +``` +sudo launchctl start com.apple.bootpd +``` + +If that doesn't work for you, try : + +``` +sudo launchctl load -w /System/Library/LaunchDaemons/bootps.plist +``` + +### [Windows, with Hyper-V] Stale internet connection sharing lease + +Another possible reason for instance timeouts is a problem with the `Internet Connection Sharing` hosts file. This file sometimes gets corrupted, with jumbled or incomplete text. Other times, it contains duplicate or stale IP addresses. + +Using Administrator privileges, edit the file `C:\WINDOWS\System32\drivers\etc\hosts.ics` and look for any corruption or entries that have your instance name in it. If there is more than one entry, remove any of them except for the first one listed. Save the file and try again. If that does not work, stop any running instances, delete the file, and reboot. + +### SSH issues **(DRAFT)** + +If SSH doesn't function properly in the VM, or Multipass is blocked from accessing it, your instance may need to be reconfigured or repaired. + +* If the default user is not `ubuntu`, Multipass cannot connect. If you used a custom cloud-init config file, make sure that the default user is `ubuntu`. + +* if SSH keys are missing or incorrect, you will have to add your public SSH key from `~/.ssh/id_rsa.pub` on the host to `~/.ssh/authorized_keys` in the instance. To do so you may need to gain access to the instance through a method besides SSH. + +To gain access to an instance without SSH you can try the following methods. + +* [Mount the instance's image file](#reading-data-from-a-qcow2-image-13) on your host and make necessary changes through the filesystem. + +* Run the instance VM directly. This will require a username and password to log in. The username is the default user, `ubuntu`, and the password is what was set in cloud-init if you used a custom cloud-init config. If you do not have a password you can modify the instance's `cloud-init-config.iso` file to change it. One way to do so is as follows. + 1. Back up your existing `cloud-init-config.iso`. + 2. Make a new instance by running `multipass launch --cloud-init config.yaml`, the contents `config.yaml` are shown below. + 3. Replace your existing `cloud-init-config.iso` with the newly generated `cloud-init-config.iso`. + 4. Restart the VM and use the password `ubuntu`. The instance's password will remain `ubuntu` unless it is changed again + 5. Make necessary changes. + +``` +#cloud-config +password: ubuntu +chpasswd: { expire: false } +``` + +### Cloud-init tarries during an instance launch **(DRAFT)** + +- When launching a new instance, once Multipass obtains an SSH session to the instance, it will wait for cloud-init to complete. During this phase, the CLI/GUI spinner reads "Waiting for initialization to complete". + +- At this point, the initialization continues in the background, even if you interrupt the launch command or if it times out. + +- So if you wait for a little while longer, your instance may eventually finish setting up. When it does, it will have this file: `/var/lib/cloud/instance/boot-finished`. + * Consider passing a longer timeout to the `launch` command. For example, `multipass launch --timeout 1000` sets the launch timeout to 1000 seconds. + +* You can use `multipass shell` to get a shell in the instance when Multipass is waiting for cloud-init to finish. To diagnose problems, inspect cloud-init's logs in `/var/log/cloud-init*log`. + +### [Windows, VirtualBox driver] Running VirtualBox with the system account + +To run the VirtualBox GUI with the system account, you will need a Windows tool called PsExec: + +1. Install [PsExec](https://docs.microsoft.com/en-us/sysinternals/downloads/psexec) +1. Add it to your `PATH` +1. Run PowerShell as Administrator +1. Execute `psexec.exe -s -i "C:\Program Files\Oracle\VirtualBox\VirtualBox.exe"` (adapt the path to the VirtualBox executable as needed) + +When successful, you should see Multipass's instances in VirtualBox + +### Stale network cache + +This can be caused by a known Qt bug (see issue [#1714](https://github.com/canonical/multipass/issues/1714) on our GitHub). + +A workaround to resolve this issue is to run the command `multipass find --force-update`, which forces downloading the image information from the network. As a result, if the download is successful, the `network-cache` will be overwritten. + +Alternatively, try deleting the `network-cache` folder and restart the Multipass service: + +* (on Linux) + ``` + sudo snap stop multipass + sudo rm -rf /var/snap/multipass/common/cache/multipassd/network-cache/ + sudo snap start multipass + ``` +* (on macOS) + ``` + sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist + sudo rm -rf /System/Volumes/Data/private/var/root/Library/Caches/multipassd/network-cache + sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist + ``` +* (on Windows) + Remove `C:\ProgramData\Multipass\cache\network-cache` and restart the Multipass service. + +### Reading data from a QCOW2 image + +The images that Multipass uses with the QEMU driver follow a standard format — QCOW2 — which other tools can read. + +One example is [`qemu-nbd`](https://manpages.ubuntu.com/manpages/oracular/en/man8/qemu-nbd.8.html), which allows mounting the image. This tool is not shipped with Multipass, so you would need to install it manually. + +Once you have it, you can search the web for recipes to "mount a QCOW2 image". For example, here is a [a recipe](https://askubuntu.com/a/4404). + +### Locating Multipass Binaries **(DRAFT)** +You may need to locate where Multipass is installed. There are several ways to do so, depending on your platform: +* (on Linux) + * Run the command `which multipass` or `whereis multipass`. + * By default, Multipass is installed in the `/snap/bin` folder. + +* (on Windows) + * Run the command `where.exe multipass`. + * Right-click a shortcut to Multipass in your files or Start menu and select "Open file location". + * By default, Multipass is installed in the `C:\Program Files\Multipass\bin` folder. + +* (on MacOS) + * Run the command `readlink -f $(which multipass)` + * By default, Multipass is installed in the `/Library/Application\ Support/com.canonical.multipass/bin/` folder. + +### Locating Multipass Images **(DRAFT)** +You may need to locate where Multipass is storing instances. The location changes depending on your platform: +* (Linux) `/root/.local/share/multipassd/vault/instances/` + +* (Windows) `C:\ProgramData\Multipass\data\vault\instances\\` + +* (MacOS) `/var/root/Library/Application\ Support/multipassd/qemu/vault/instances//` + diff --git a/docs/how-to-guides/troubleshoot/troubleshoot-networking.md b/docs/how-to-guides/troubleshoot/troubleshoot-networking.md new file mode 100644 index 0000000000..9d7f490b14 --- /dev/null +++ b/docs/how-to-guides/troubleshoot/troubleshoot-networking.md @@ -0,0 +1,322 @@ +# Troubleshoot networking + + +This document demonstrates how to troubleshoot various known Multipass networking issues on macOS and Windows. + +## Troubleshoot networking on macOS + +### Architecture + +On macOS, the QEMU driver employs the Hypervisor.framework. This framework manages the networking stack for the instances. + +On creation of an instance, the Hypervisor framework on the host uses macOS’ **Internet Sharing** mechanism to: + +1. Create a virtual switch and connect each instance to it (subnet 192.168.64.*). +2. Provide DHCP and DNS resolution on this switch at 192.168.64.1 (via bootpd & mDNSResponder services running on the host). This is configured by an auto-generated file (`/etc/bootpd.plist`), but editing this is pointless as MacOS regenerates it as it desires. + +Note that, according to **System Preferences > Sharing**, the **Internet Sharing** service can appear disabled. This is fine---in the background, it will still be enabled to support instances. + +### Tools known to interfere with Multipass + +* VPN software can be aggressive at managing routes and may route 192.168.64 subnet through the VPN interface, instead of keeping it locally available. + * Possible culprits: OpenVPN, F5, Dell SonicWall, Cisco AnyConnect, Citrix/Netscaler Gateway, Jupiter Junos Pulse / Pulse Secure + * Tunnelblick doesn’t cause problems +* Cisco Umbrella Roaming Client it binds to localhost:53 which clashes with Internet Sharing, breaking instance’s DNS (ref: [Umbrella Roaming Client OS X and Internet Sharing](https://support.umbrella.com/hc/en-us/articles/230561007-Umbrella-Roaming-Client-OS-X-and-Internet-Sharing)) +* dnscrypt-proxy/dnscrypt-wrapper/cloudflared-proxy \ +Default configuration binds to localhost port 53, clashing with Internet Sharing. +* another dnsmasq process bound to localhost port 53 +* custom DHCP server bound to port 67? ("sudo lsof -iUDP:67 -n -P" should show launchd & bootpd only) +* MacOS update can make changes to the firewall and leave instances in unknown state (see [below](heading--issues-caused-by-macos-update)). + +### Problem class + +* `multipass launch` fails + * go to ["Generic networking" section](#generic-networking-problems) +* `multipass shell ` fails + * go to ["Network routing" section](#network-routing-problems) +* `multipass shell ` works but the instance cannot connect to the internet + * go to ["DNS" section](#dns-problems) +* extra IPs not reachable between instances + * go to ["ARP" section](#arp-problems) + +#### Generic networking problems + +`Unable to determine IP address` usually implies some networking configuration is incompatible, or there is interference from a Firewall or VPN. + + + +##### Troubleshooting + +1. Firewall + 1. Is Firewall enabled? + 1. If so it must not "Block all incoming connections" + * Blocking all incoming connections prevents a DHCP server from running locally, to give an IP to the instance. + * It’s OK to block incoming connections to "multipassd" however. +1. VPN +1. Little Snitch - defaults are good, it should permit mDNSResponder and bootpd access to BPF +If you're having trouble downloading images and/or see `Unknown error`s when trying to `multipass launch -vvv`, Little Snitch may be interfering with `multipassd`'s network access (ref. [#1169](https://github.com/CanonicalLtd/multipass/issues/1169)) +1. Internet Sharing - doesn’t usually clash +1. Is the bootpd DHCP server alive? (`sudo lsof -iUDP:67 -n -P` should mention `bootpd`) + - It should be launched automatically when there is a request, but you can also launch it manually if needed. + - Start it by running `sudo launchctl start com.apple.bootpd`. If that doesn't work for you, try `sudo launchctl load -w /System/Library/LaunchDaemons/bootps.plist`. + +#### Network routing problems + +You could try: + +```plain +sudo route -nv add -net 192.168.64.0/24 -interface bridge100 +``` + +If you get a "File exists" error, maybe delete and retry? + +```plain +sudo route -nv delete -net 192.168.64.0/24 +sudo route -nv add -net 192.168.64.0/24 -interface bridge100 +``` + +Maybe `-static` route helps? + +If using Cisco AnyConnect, try using OpenConnect (`brew install openconnect`) instead as it messes with routes less (but your company sysadmin/policy may not permit/authorize this). + +* It monitors the routing table so may prevent any customisation. Here is [a very hacky workaround](https://unix.stackexchange.com/questions/106304/route-add-no-longer-works-when-i-connected-to-vpn-via-cisco-anyconnect-client/501094#501094). + +Does your VPN software provide a "split connection" option, where VPN sysadmin can designate a range of IP addresses to **not** be routed through the VPN? +* Cisco does +* Pulse Secure / Jupiter Junos Pulse do + +#### Potential workaround for VPN conflicts + +This was reported on GitHub (issue [#495](https://github.com/CanonicalLtd/multipass/issues/495#issuecomment-448461250)). + +After the `nat …` line (if there is one, otherwise at the end) in `/etc/pf.conf`, add this line: + +```plain +nat on utun1 from bridge100:network to any -> (utun1) +``` + +and reload PF with the command: + +```plain +sudo pfctl -f /etc/pf.conf +``` + +#### Configure Multipass to use a different subnet + +Edit `/Library/Preferences/SystemConfiguration/com.apple.vmnet.plist` to change the "Shared_Net_Address" value to something other than `192.168.64.1 -`. +* it works if you edit the plist file and stay inside 192.168 range, as Multipass hardcoded for this + +```{note} +If you change the subnet and launch an instance, it will get an IP from that new subnet. But if you try changing it back, the change is reverted on next instance start. It appears that the DHCP server reads the last IP in `/var/db/dhcpd_leases`, decides the subnet from that, and updates Shared_Net_Address to match. So, the only way to really revert this change is to edit or delete `/var/db/dhcpd_leases`. +``` + +#### DNS problems + +Can you ping IP addresses? + +```plain +ping 1.1.1.1 +``` + +If not, the output will be similar to the following: + +```plain +PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data. +^C +--- 1.1.1.1 ping statistics --- +3 packets transmitted, 0 received, 100% packet loss, time 2030ms +``` + +Note that macOS’s firewall can block the ICMP packets that `ping` uses, which will interfere with this test. Make sure you disable **Stealth Mode** in **System Preferences > Security & Privacy > Firewall** just for this test. + +![Security & Privacy|690x605](upload://nvrMzXqFsN0vezA5Fd77k5K65xo.jpg "Security and Privacy") + +If you try again, it should work: + +```plain +ping 1.1.1.1 +``` + +The output will be similar to the following: + +```plain +PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data. +64 bytes from 1.1.1.1: icmp_seq=1 ttl=53 time=7.02 ms +64 bytes from 1.1.1.1: icmp_seq=2 ttl=53 time=5.91 ms +64 bytes from 1.1.1.1: icmp_seq=3 ttl=53 time=5.12 ms +^C +--- 1.1.1.1 ping statistics --- +3 packets transmitted, 3 received, 0% packet loss, time 2143ms +rtt min/avg/max/mdev = 5.124/6.020/7.022/0.781 ms +``` + +This means the instance can indeed connect to the internet, but DNS resolution is broken. You can test DNS resolution using the `dig` tool: + +```plain +dig @192.168.64.1 google.ie +``` + +If broken, the output will be similar to: + +```plain +; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.ie +;; global options: +cmd +;; connection timed out; no servers could be reached +``` + +On the other hand, if it works correctly the output will be similar to: + +```plain +; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.ie +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48163 +;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 4096 +;; QUESTION SECTION: +;google.ie. IN A + +;; ANSWER SECTION: +google.ie. 15 IN A 74.125.193.94 + +;; Query time: 0 msec +;; SERVER: 192.168.64.1#53(192.168.64.1) +;; WHEN: Thu Aug 01 15:17:04 IST 2019 +;; MSG SIZE rcvd: 54 +``` + +To test further, try supplying an explicit DNS server: + +```plain +dig @1.1.1.1 google.ie +``` + +If it works correctly, the output will be similar to: + +```plain +; <<>> DiG 9.10.3-P4-Ubuntu <<>> @1.1.1.1 google.ie +; (1 server found) +;; global options: +cmd +;; Got answer: +;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11472 +;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 + +;; OPT PSEUDOSECTION: +; EDNS: version: 0, flags:; udp: 1452 +;; QUESTION SECTION: +;google.ie. IN A + +;; ANSWER SECTION: +google.ie. 39 IN A 74.125.193.94 + +;; Query time: 6 msec +;; SERVER: 1.1.1.1#53(1.1.1.1) +;; WHEN: Thu Aug 01 15:16:27 IST 2019 +;; MSG SIZE rcvd: 54 +``` + +This implies the problem is with the macOS **Internet Sharing** feature---for some reason, its built-in DNS server is broken. + +The built-in DNS server should be "mDNSResponder", which binds to localhost on port 53. + +If using Little Snitch or another per-process firewall, ensure mDNSResponder can establish outgoing connections. MacOS’ built-in firewall should not interfere with it. + +Check what is bound to that port on the host with: + +```plain +sudo lsof -iTCP:53 -iUDP:53 -n -P +``` + +The sample output below shows the correct state while a instance is running: + +```plain +sudo lsof -iTCP:53 -iUDP:53 -n -P +COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME +mDNSRespo 191 _mdnsresponder 17u IPv4 0xa89d451b9ea11d87 0t0 UDP *:53 +mDNSRespo 191 _mdnsresponder 25u IPv6 0xa89d451b9ea1203f 0t0 UDP *:53 +mDNSRespo 191 _mdnsresponder 50u IPv4 0xa89d451b9ea8b8cf 0t0 TCP *:53 (LISTEN) +mDNSRespo 191 _mdnsresponder 55u IPv6 0xa89d451b9e2e200f 0t0 TCP *:53 (LISTEN) +``` + +If no instance is running (and **Internet Sharing** is disabled in **System Preferences**), the command should return nothing. + +Any other command appearing in that output means a process is conflicting with **Internet Sharing** and thus will break DNS in the instance. + +##### Possible workarounds + +1. Configure DNS inside the instance to use an external working DNS server. Can do so by appending this line to /etc/resolv.conf manually: + + ``` + nameserver 1.1.1.1 + ``` + + "1.1.1.1" is a free DNS service provided by CloudFlare, but you can use your own. +2. Use a [custom cloud-init to set /etc/resolv.conf](https://cloudinit.readthedocs.io/en/latest/topics/examples.html?highlight=dns#configure-an-instances-resolv-conf) for you on first boot. + +#### ARP problems + +The macOS bridge by Multipass filters packets so that only the IP address originally assigned to the VM is allowed through. If you add an additional address (e.g. an IP alias) to the VM, the ARP broadcast will get through but the ARP response will be filtered out. + +This means that applications that rely on additional IP addresses, such as [metallb](https://metallb.universe.tf/) under [microk8s](https://microk8s.io/), will not work. + +#### Issues caused by MacOS update + +When upgrading MacOS to 12.4 (this might happen however also when upgrading to other vesions), MacOS makes changes to the firewall. If the instances are not stopped before the update, it is possible the connection to the instances are blocked by the MacOS firewall. We cannot know what is exactly the change introduced to the firewall, it seems the Apple's `bootpd` stops replying DHCP requests. + +There are some procedures that can help to overcome this issue (see [issue #2387](https://github.com/canonical/multipass/issues/2387) on the Multipass GitHub repo for a discussion on this and some alternative solutions). First, you can try to: + +* Reboot the computer. +* Disable and then reenable Internet sharing and/or the firewall. +* Configure the driver (QEMU) and Multipass in the firewall to allow incoming connections. + +## Troubleshoot networking on Windows + +### Architecture + +Multipass uses the native "Hyper-V" hypervisor on Windows, along with the "Default Switch" created for it. That, in turn, uses the "Internet Sharing" functionality, providing DHCP (IP addresses) and DNS (domain name resolution) to the instances. + +### Known issues + +#### Default switch going awry + +Unfortunately the default switch is known to be quirky and Windows updates often put it in a weird state. This may result in new instances failing to launch and existing ones timing out to start. + +The broken state also persists over reboots. The one approach that has helped is removing the network sharing from the default switch: + +```powershell +Get-HNSNetwork | ? Name -Like "Default Switch" | Remove-HNSNetwork +``` + +and then rebooting the system: + +```powershell +Restart-Computer +``` + +Hyper-V will recreate it on next boot. + +#### Stale Internet connection sharing lease + + + +Another reason for instance timeouts may be that a "stale" IP address for a particular instance name is stored in the `Internet Connection Sharing` hosts file. + +Using Administrator privileges, edit the file `C:\WINDOWS\System32\drivers\etc\hosts.ics` and look for any entries that have your instance name in it. If there is more than 1 entry, remove any of them except for the first listed. Save the file and try again. + +#### Anti-virus / security software blocking instances + +Anti-virus and network security software are not necessarily virtualization-aware. If you’re having issues with connectivity, temporarily disabling this software to test can result in a positive outcome. Examples of this software are Symantec, ESET, Kaspersky and Malware Bytes. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @saviq , @townsend , @sowasred2012 , @ya-bo-ng , @candlerb , @sergiusens , @nhart , @andreitoterman , @tmihoc , @luisp , @ricab , @gzanchi , @naynayu , @QuantumLibet + diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 0000000000..4ef6476c12 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,60 @@ + + + +# Multipass documentation + +Multipass is a tool to generate cloud-style Ubuntu VMs quickly on Linux, macOS and Windows. It provides a simple but powerful CLI that enables you to quickly access an Ubuntu command line or create your own local mini-cloud. + +Local development and testing can be challenging, but Multipass simplifies these processes by automating setup and teardown. Multipass has a growing library of images that you can use to launch purpose-built VMs or custom VMs you’ve configured yourself through its powerful `cloud-init` interface. + +Developers can use Multipass to prototype cloud deployments and to create fresh, customized Linux dev environments on any machine. Multipass is the quickest way for Mac and Windows users to get an Ubuntu command line on their systems. You can also use it as a sandbox to try new things without affecting your host machine or requiring a dual boot. + +--- + +## In this documentation + +| | | +|------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------| +| [Tutorial](/tutorial/tutorial)
Get started - a hands-on introduction to Multipass for new users
| [How-to guides](/how-to-guides/how-to-guides)
Step-by-step guides covering key operations and common tasks | +| [Explanation](/explanation/explanation)
Concepts - discussion and clarification of key topics | [Reference](/reference/reference)
Technical information - specifications, APIs, architecture | + +--- + +## Project and community + +We value your input and contributions! Here are some ways you can join our community or get help with your Multipass questions: + +* Read our [Code of Conduct](https://ubuntu.com/community/code-of-conduct) +* Read our quick guide: [Contribute to Multipass docs](/contribute-to-multipass-docs) +* Join the [Discourse forum](https://discourse.ubuntu.com/c/multipass/21) +* Report an issue or contribute to the code on [GitHub](https://github.com/canonical/multipass/issues) + + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @nhart, @saviq, @townsend, @andreitoterman, @tmihoc, @luisp, @ricab, @sharder996, @georgeliaojia, @gzanchi + + +```{toctree} +:hidden: +:titlesonly: +:maxdepth: 2 +:glob: + +Home +tutorial +/how*/index +/reference*/index +/explanation*/index +contribute-to-multipass-docs diff --git a/docs/log.txt b/docs/log.txt new file mode 100644 index 0000000000..0699e6c86c --- /dev/null +++ b/docs/log.txt @@ -0,0 +1,22 @@ +. .sphinx/venv/bin/activate; .sphinx/venv/bin/sphinx-autobuild -b dirhtml "src" "_build" -c . -d .sphinx/.doctrees -j auto +Running Sphinx v7.4.7 +loading translations [en]... done +matplotlib is not installed, social cards will not be generated +loading pickled environment... done +myst v4.0.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'substitution', 'linkify', 'deflist'}, disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, suppress_warnings=[], highlight_code_blocks=True) +building [mo]: targets for 0 po files that are out of date +writing output... +building [dirhtml]: targets for 0 source files that are out of date +updating environment: 0 added, 0 changed, 0 removed +reading sources... +getting Git timestamps for source files... +getting Git timestamps for dependencies... +looking for now-outdated files... none found +no targets are out of date. +build succeeded. + +The HTML pages are in _build. +[sphinx-autobuild] Starting initial build +[sphinx-autobuild] > python -m sphinx build -b dirhtml src _build -c . -d .sphinx/.doctrees -j auto +[sphinx-autobuild] Serving on http://127.0.0.1:8000 +[sphinx-autobuild] Waiting to detect changes... diff --git a/docs/reference/command-line-interface/alias.md b/docs/reference/command-line-interface/alias.md new file mode 100644 index 0000000000..d6b568bdf1 --- /dev/null +++ b/docs/reference/command-line-interface/alias.md @@ -0,0 +1,43 @@ +# alias +> See also: [Alias](/explanation/alias), [How to use command aliases](/how-to-guides/manage-instances/use-instance-command-aliases). + +The `alias` command makes Multipass create a persistent alias to run commands on a given instance. Its syntax is the following: + +```plain +multipass alias instance:command [name] +``` + +If `name` is omitted, the alias name defaults to `command`. + +After running this command, a new alias is defined as running the `command` on the given instance. + +By default, if the host folder where the alias is being executed is mounted on the instance, the instance's working directory is changed to the mounted directory. This behaviour can be avoided by defining the alias with the option `--no-map-working-directory`. + +--- + +The full `multipass help alias` output explains the available options: + +```plain +Usage: multipass alias [options] [] +Create an alias to be executed on a given instance. + +Options: + -h, --help Displays help on commandline options + -v, --verbose Increase logging verbosity. Repeat the 'v' in + the short option for more detail. Maximum + verbosity is obtained with 4 (or more) v's, + i.e. -vvvv. + -n, --no-map-working-directory Do not automatically map the host execution + path to a mounted path + +Arguments: + definition Alias definition in the form + : + name Name given to the alias being defined, + defaults to +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/command-line-interface/aliases.md b/docs/reference/command-line-interface/aliases.md new file mode 100644 index 0000000000..9597b8d0c6 --- /dev/null +++ b/docs/reference/command-line-interface/aliases.md @@ -0,0 +1,49 @@ +# aliases +> See also: [Alias](/explanation/alias), [How to use command aliases](/how-to-guides/manage-instances/use-instance-command-aliases) + +The `aliases` command shows the aliases defined for all the instances. + +```plain +multipass aliases +``` + +The output will be similar to the following: + +```plain +Alias Instance Command Working directory +lsrm rewarded-merlin ls default +topfp flying-pig top map +``` + +The `Working directory` column tells us the directory of the host where the alias will be run. The value `default` means that the alias will be run in the instance's default working directory (normally, `/home/ubuntu`). The value `map` means that, if the host directory from which the user calls the alias is mounted on the instance, the alias will be run on the mounted directory on the instance. + +[note type="information"] +The value will be `default` only if the alias was created with the `--no-map-working-directory` option. +``` + +The command can be used in conjunction with the `--format` or `-f` options to specify the desired output format: `csv`, `json`, `table` or `yaml`. + +--- + +The full `multipass help aliases` output explains the available options: + +```plain +Usage: multipass aliases [options] +List available aliases + +Options: + -h, --help Displays help on commandline options + -v, --verbose Increase logging verbosity. Repeat the 'v' in the short + option for more detail. Maximum verbosity is obtained with + 4 (or more) v's, i.e. -vvvv. + --format Output list in the requested format. Valid formats are: + table (default), json, csv and yaml. The output working + directory states whether the alias runs in the instance's + default directory or the alias running directory should try + to be mapped to a mounted one. +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/command-line-interface/authenticate.md b/docs/reference/command-line-interface/authenticate.md new file mode 100644 index 0000000000..53b4f12ec3 --- /dev/null +++ b/docs/reference/command-line-interface/authenticate.md @@ -0,0 +1,38 @@ +# authenticate +> See also: [Authentication](/explanation/authentication), [How to authenticate clients with the Multipass service](/how-to-guides/customise-multipass/authenticate-clients-with-the-multipass-service), [`local.passhprase`](/reference/settings/local-passphrase) + +The `authenticate` command is used to authenticate a client with the Multipass service. Once authenticated, the client can issue commands such as `list`, `launch`, etc. + +To help reduce the amount of typing for `authenticate`, one can also use `multipass auth` as an alias: + +```plain +multipass auth foo +``` + +If no passphrase is specified in the `multipass authenticate` command line, you will be prompted to enter it. + +--- + +The full `multipass help authenticate` output explains the available options: + +```plain +Usage: multipass authenticate [options] [] +Authenticate with the Multipass service. +A system administrator should provide you with a passphrase +to allow use of the Multipass service. + +Options: + -h, --help Displays help on commandline options + -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option + for more detail. Maximum verbosity is obtained with 4 (or more) + v's, i.e. -vvvv. + +Arguments: + passphrase Passphrase to register with the Multipass service. If omitted, + a prompt will be displayed for entering the passphrase. +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/command-line-interface/clone.md b/docs/reference/command-line-interface/clone.md new file mode 100644 index 0000000000..1a2ac5bfe8 --- /dev/null +++ b/docs/reference/command-line-interface/clone.md @@ -0,0 +1,51 @@ +# clone +The `multipass clone` command creates a clone of an instance. A cloned instance is a standalone instance that is a replica of the original instance in terms of its configuration, installed software, and data at the time of cloning. Cloning an instance can be useful for backup or testing purposes, or to create identical VMs from a working template. + +```{caution} +The `clone` command is available since Multipass version 1.15.0. +``` + +Currently, only instances that are in the `Stopped` state can be cloned. + +You can run the `clone` command on a source instance without any additional options. For example, `multipass clone natty-nilgai` will produce the following output: + +```plain +… +Cloned from natty-nilgai to natty-nilgai-clone1. +``` + +By default, the `multipass clone` command automatically generates a name for the cloned instance using the format *-cloneN*, where *N* represents the number of instances cloned from that specific source instance, starting at 1. In the example, the name of the source VM is "natty-nilgai" and the automatically generated name for its clone is "natty-nilgai-clone1". + +Alternatively, you can specify a custom name for the cloned instance using `--name` option, following the [standard instance name format](/reference/instance-name-format). For example: + +``` +multipass clone natty-nilgai --name custom-clone +``` + +--- + +The full `multipass help clone` output explains the available options: + +```plain +Usage: multipass clone [options] +Create an independent copy of an existing (stopped) instance. + +Options: + -h, --help Displays help on commandline options + -v, --verbose Increase logging verbosity. Repeat the 'v' in + the short option for more detail. Maximum + verbosity is obtained with 4 (or more) v's, + i.e. -vvvv. + -n, --name An optional custom name for the cloned + instance. The name must follow the usual + validity rules (see "help launch"). Default: + "-cloneN", where N is the Nth + cloned instance. + +Arguments: + source_name The name of the source instance to be cloned +``` +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/command-line-interface/delete.md b/docs/reference/command-line-interface/delete.md new file mode 100644 index 0000000000..b378c0c852 --- /dev/null +++ b/docs/reference/command-line-interface/delete.md @@ -0,0 +1,49 @@ +# delete +> See also: [`recover`](/reference/command-line-interface/recover), [`purge`](/reference/command-line-interface/purge) + +The `multipass delete` command deletes the instances or snapshots that are specified as arguments. + +You can provide multiple arguments in the same delete command, including both instances and snapshots; for example: + +```plain +multipass delete --purge legal-takin calm-squirrel.snapshot2 +``` + +Deleted instances are marked as such and removed from use, but you can still recover them using the `multipass recover` command, unless you used the `-p`/`--purge` option to delete them permanently. + +To completely destroy instances and release the disk space they take up, use the `--purge` option or the [`multipass purge`](/reference/command-line-interface/purge) command. + +```{caution} +When you delete a [snapshot](/explanation/snapshot), or when you delete an instance using the [GUI client](/reference/gui-client), Multipass removes them permanently (even if you didn't use the `--purge` option) and they cannot be recovered. + +``` + +The `--all` option will delete all instances and their snapshots. Take care if using this option. + +--- + +The output of `multipass help delete` explains the available options: + +```plain +Usage: multipass delete [options] [.snapshot] [[.snapshot] ...] +Delete instances and snapshots. Instances can be purged immediately or later on, +with the "purge" command. Until they are purged, instances can be recovered +with the "recover" command. Snapshots cannot be recovered after deletion and must be purged at once. + +Options: + -h, --help Displays help on commandline options + -v, --verbose Increase logging verbosity. Repeat the 'v' in the short option + for more detail. Maximum verbosity is obtained with 4 (or more) + v's, i.e. -vvvv. + --all Delete all instances and snapshots + -p, --purge Permanently delete specified instances and snapshots + immediately + +Arguments: + name Names of instances and snapshots to delete +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/command-line-interface/exec.md b/docs/reference/command-line-interface/exec.md new file mode 100644 index 0000000000..8b0d6603c9 --- /dev/null +++ b/docs/reference/command-line-interface/exec.md @@ -0,0 +1,75 @@ +# exec +> See also: [Multipass `exec` and shells](/explanation/multipass-exec-and-shells), [How to use instance command aliases](/how-to-guides/manage-instances/use-instance-command-aliases) + +The `exec` command runs the given commands inside the instance. The first argument is the instance to run the commands on, `--` optionally separates the `multipass` options from the rest - the command to run itself: + +```plain +multipass exec primary -- uname -r +``` + +Sample output: + +```plain +4.15.0-48-generic +``` + +You can pipe standard input and output to/from the command; for example: + +```plain +multipass exec primary -- lsb_release -a | grep ^Codename: +``` + +Sample output: + +```plain +No LSB modules are available. +Codename: bionic +``` + +The `--` separator is required if you want to pass options to the command being run. Options to the `exec` command itself must be specified before `--`. + +You can specify on which instance directory the command must be run in three different ways. + +The first one is `--working-directory `, which tells Multipass that the command must be run in the folder ``. For example: + +```plain +multipass exec arriving-pipefish --working-directory /home -- ls -a +``` + +The `ls -la` command shows the contents of the `/home` directory, because it was run from there: + +```plain +. .. ubuntu +``` + +The second option to specify the working directory is to look through the mounted folders first. In case we are running the alias on the host from a directory which is mounted on the instance, the command will be run on the instance from there. If the working directory is not mounted on the instance, the command will be run on the default directory on the instance. This is the default behaviour and no parameter must be specified for this mapping to happen. + +The third option is to directly run the command in the default directory in the instance (usually, it is `/home/ubuntu`. The parameter to force this behaviour is `--no-map-working-directory`. + +--- + +The full `multipass help exec` output explains the available options: + +```plain +Usage: multipass exec [options] [--] +Run a command on an instance + +Options: + -h, --help Displays help on commandline options + -v, --verbose Increase logging verbosity. Repeat the 'v' in + the short option for more detail. Maximum + verbosity is obtained with 4 (or more) v's, + i.e. -vvvv. + -d, --working-directory Change to before execution + -n, --no-map-working-directory Do not map the host execution path to a + mounted path + +Arguments: + name Name of instance to execute the command on + command Command to execute on the instance +``` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/command-line-interface/find.md b/docs/reference/command-line-interface/find.md new file mode 100644 index 0000000000..13bcace8e4 --- /dev/null +++ b/docs/reference/command-line-interface/find.md @@ -0,0 +1,7 @@ +# find + + +These instance states reflect the various stages an instance can be in while using Multipass. Instances in different states can accept different commands. See [Multipass CLI commands](/t/multipass-cli-commands/29329) for more information on which commands can be used and when. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/logging-levels.md b/docs/reference/logging-levels.md new file mode 100644 index 0000000000..dee394983c --- /dev/null +++ b/docs/reference/logging-levels.md @@ -0,0 +1,29 @@ +# Logging levels +> See also: [Configure Multipass’s default logging level](/how-to-guides/customise-multipass/configure-multipasss-default-logging-level) + +In Multipass, a hierarchy of logging levels is used is used to convey severity and improve visibility of important events. Multipass uses the following levels ranked from most severe to least severe for its background daemon and child processes. + +## Error + +Indicates a failure that prevents the intended operation from being accomplished in its entirety. If there is a corresponding CLI command, it should exit with an error code. + +## Warning + +Indicates an event or fact that might not correspond to the user's intentions/desires/beliefs, or a problem that is light enough that it does not prevent main goals from being accomplished. If there is a corresponding CLI command, it should exit with a success code. + +## Info + +Indicates information that may be useful for the user to know, learn, etc. + +## Debug + +Indicates information that is useful for developers and troubleshooting. + +## Trace + +Indicates information that may be helpful for debugging, but which would clutter logs unreasonably if enabled by default. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/client-apps-windows-terminal-profiles.md b/docs/reference/settings/client-apps-windows-terminal-profiles.md new file mode 100644 index 0000000000..49e0f9c74a --- /dev/null +++ b/docs/reference/settings/client-apps-windows-terminal-profiles.md @@ -0,0 +1,31 @@ +# client.apps.windows-terminal.profiles +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [How to integrate with Windows Terminal](/how-to-guides/customise-multipass/how-to-integrate-with-windows-terminal) + +## Key + +`client.apps.windows-terminal.profiles` + +## Description + +Which profiles should be enabled in Windows Terminal. + + +## Possible values + +The following values are supported: + + - `primary` to enable a profile for the [primary instance](/t/28469#primary-instance). Note that this value is independent of what primary name is configured. + - `none` to disable any profiles. + +## Examples + +- `multipass set client.apps.windows-terminal.profiles=none` + +## Default value + +`primary` (a profile for `primary` is added when Windows Terminal is found) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/client-gui-autostart.md b/docs/reference/settings/client-gui-autostart.md new file mode 100644 index 0000000000..c5823d6015 --- /dev/null +++ b/docs/reference/settings/client-gui-autostart.md @@ -0,0 +1,32 @@ +# client.gui.autostart +```{caution} +This setting has been removed from the CLI starting from Multipass version 1.14. +It is now only available in the [GUI client](/reference/gui-client). +``` + +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [GUI client](/reference/gui-client) + +## Key + +`client.gui.autostart` + +## Description + +Whether or not the Multipass GUI should start automatically on startup. + +## Possible values + +Any case variations of `on`|`off`, `yes`|`no`, `1`|`0` or `true`|`false`. + +## Examples + +`multipass set client.gui.autostart=true` + +## Default value + +`true` (on Linux and macOS it only takes effect after the client (CLI or GUI) is run for the first time) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/client-gui-hotkey.md b/docs/reference/settings/client-gui-hotkey.md new file mode 100644 index 0000000000..fd06ffe76a --- /dev/null +++ b/docs/reference/settings/client-gui-hotkey.md @@ -0,0 +1,48 @@ +# client.gui.hotkey +```{caution} +This setting has been removed from the CLI starting from Multipass version 1.14. +It is now only available in the [GUI client](/reference/gui-client). +``` + +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [GUI client](/reference/gui-client) + +## Key + +`client.gui.hotkey` + +## Description + +A keyboard shortcut for the GUI to open a shell into the [primary instance](/t/28469#primary-instance). + +## Possible values + +A single case-insensitive sequence of keys, containing: + + * zero or more modifiers (such as `Ctrl`, `Alt`, `Cmd`, `Command`, `Opt`, etc.) + * one non-modifier key (such as `u`, `4`, `.`, `Space`, `Tab`, `Pause`, `F3`). When key names have multiple words, quote and use spaces (for example: `"Print Screen"`). + * (on macOS) alternatively, UTF-8 characters for Mac keys (such as ⌘, ⌥, ⇧, ⌃) + * a plus (`+`) sign separating each alphabetic word (but not key symbols) from the next + * the empty string (`""`) to disable the hotkey + +```{caution} +**Caveats:** +- There are some limitations on what keys and combinations are supported, depending on multiple factors such as keyboard, mapping, and OS (e.g. `AltGr`, numpad, or media keys may or may not work; `shift+enter` is rejected). +- Some combinations may be grabbed by the OS before they reach multipass (e.g. `meta+a` may open the Applications, `ctrl+alt+f3` may move ttys). +``` + +## Examples + + * `multipass set client.gui.hotkey="Ctrl+Print Screen"`. + * `multipass set client.gui.hotkey="⌃⇧Y"`. + * `multipass set client.gui.hotkey=option+space`. + * `multipass set client.gui.hotkey=""` + +## Default value + +* `Ctrl+Alt+U` on Linux and Windows +* `⌥⌘U` on macOS + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/client-primary-name.md b/docs/reference/settings/client-primary-name.md new file mode 100644 index 0000000000..f65635a991 --- /dev/null +++ b/docs/reference/settings/client-primary-name.md @@ -0,0 +1,30 @@ +# client.primary-name +> See also: [Instance](/explanation/instance), [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`launch`](/reference/command-line-interface/launch) + +## Key + +`client.primary-name` + +## Description + +The name of the instance that is launched/recognized as primary. + +> See also: [Primary instance](/t/28469#primary-instance) + +## Possible values + +Any valid instance name or the empty string (`""`) to disable primary. + +## Examples + +- `multipass set client.primary-name=asdf` +- `multipass set client.primary-name=` + +## Default value + +`primary` + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/index.md b/docs/reference/settings/index.md new file mode 100644 index 0000000000..27d1973d9e --- /dev/null +++ b/docs/reference/settings/index.md @@ -0,0 +1,64 @@ +# Settings +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [GUI client](/reference/gui-client) + +Multipass can be configured with a number of **settings** that are read and written by the [`get`](/reference/command-line-interface/get) and [`set`](/reference/command-line-interface/set) CLI commands, respectively. Some settings are also available in the [GUI client](/reference/gui-client). + +Settings are organized in a tree structure, where each individual setting is identified by a unique **key** and takes on a single **value** at any given time. + +## Settings keys + +A **settings key** is a string in the form of a dot-separated path through the settings tree (such as `client.primary-name`). It specifies a path along the settings tree, from the root to a leaf. Thus, individual settings correspond to the leaves of the settings tree. + +Conceptually, branches of the tree can be singled out with wildcards, to refer to multiple settings at once. For instance, `local..*` designates the settings that affect a specific instance. Wildcards can also be used to select separate branches. For example `local.*.cpus` refers to the number of CPUs of Multipass instances. + +## Settings values + +A **settings value** is a string whose syntax (possible values/representations) and semantics (their interpretation) is determined by the setting in question. + +Values often express common concepts (such as `true`, `false`, `42`, etc.) and are interpreted internally using the corresponding data types (such as boolean, integer, etc.). They can also be more complex (such as a key combination), but they are always specified and displayed through a string representation (for example: `Ctrl+Alt+U`). + +## Available settings + +At any given time, the available settings depend on the state of the system. Some settings are only available on some platforms, while daemon settings can only be accessed when the Multipass daemon itself can be reached. + +Some instance properties are also exposed as settings. +> See also: [Set the CPU, RAM or disk of an instance](/t/28603#set-the-cpu-ram-or-disk-of-an-instance). + +The command `multipass get --keys` shows what settings are available at any given time. + +As of now, this is the total set of settings available: + +- [`client.apps.windows-terminal.profiles`](/reference/settings/client-apps-windows-terminal-profiles) +- [`client.primary-name`](/reference/settings/client-primary-name) +- [`local..bridged`](/reference/settings/local-instance-name-bridged) +- [`local..cpus`](/reference/settings/local-instance-name-cpus) +- [`local..disk`](/reference/settings/local-instance-name-disk) +- [`local..memory`](/reference/settings/local-instance-name-memory) +- [`local...name`](/reference/settings/local-instance-name-snapshot-name-name) +- [`local...comment`](/reference/settings/local-instance-name-snapshot-name-comment) +- [`local.bridged-network`](/reference/settings/local-bridged-network) +- [`local.driver`](/reference/settings/local-driver) +- [`local.passphrase`](/reference/settings/local-passphrase) +- [`local.privileged-mounts`](/reference/settings/local-privileged-mounts) + +```{caution} +Starting from Multipass version 1.14, the following settings have been removed from the CLI and are only available in the [GUI client](/reference/gui-client): +- [`client.gui.autostart`](/reference/settings/client-gui-autostart) +- [`client.gui.hotkey`](/reference/settings/client-gui-hotkey) +``` + + + +--- + + *Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + + +```{toctree} +:hidden: +:titlesonly: +:maxdepth: 2 +:glob: + +* +*/index diff --git a/docs/reference/settings/local-bridged-network.md b/docs/reference/settings/local-bridged-network.md new file mode 100644 index 0000000000..74fad70db2 --- /dev/null +++ b/docs/reference/settings/local-bridged-network.md @@ -0,0 +1,29 @@ +# local.bridged-network +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`launch`](/reference/command-line-interface/launch), [`networks`](/reference/command-line-interface/networks), [Create an instance with multiple network interfaces](/t/27188#create-an-instance-with-multiple-network-interfaces), [Add a network to an existing instance](/how-to-guides/manage-instances/add-a-network-to-an-existing-instance), [`local..bridged`](/reference/settings/local-instance-name-bridged) + +## Key + +`local.bridged-network` + +## Description + +The name of the interface to connect the instance to when the shortcut `launch --bridged` is issued. + +## Possible values + +Any name from [`multipass networks`](/reference/command-line-interface/networks). + +Validation is deferred to [`multipass launch`](/reference/command-line-interface/launch). + +## Examples + +`multipass set local.bridged-network=en0` + +## Default value + +`` (`""`). + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-driver.md b/docs/reference/settings/local-driver.md new file mode 100644 index 0000000000..d3f87cf340 --- /dev/null +++ b/docs/reference/settings/local-driver.md @@ -0,0 +1,28 @@ +# local.driver +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [Driver](/explanation/driver), [How to use libvirt in Multipass](/) + +## Key + +`local.driver` + +## Description + +A string identifying the hypervisor back-end in use. + +## Possible values + + - `qemu`, [`libvirt`](/) and `lxd` on Linux + - `hyperv` and `virtualbox` on Windows + - `qemu` and `virtualbox` on macOS 10.15+ + - *(deprecated)* `hyperkit` on Intel macOS 10.15+ + +## Default values + + - `qemu` on macOS and amd64 Linux + - `lxd` on non-amd64 Linux + - `hyperv` on Windows + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-instance-name-bridged.md b/docs/reference/settings/local-instance-name-bridged.md new file mode 100644 index 0000000000..2dd48872ea --- /dev/null +++ b/docs/reference/settings/local-instance-name-bridged.md @@ -0,0 +1,45 @@ +# local.\.bridged +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`local.bridged-network`](/reference/settings/local-bridged-network), [How to add networks to existing instances](/how-to-guides/manage-instances/add-a-network-to-an-existing-instance) + +## Key + +`local..bridged` + +where `` is the name of a Multipass instance. + +## Description + +Whether or not the virtual machine is connected to the preferred bridge that is currently defined by `local..bridged`. + +Setting this to `true` will cause the instance to be bridged to that host network interface. + +Removing a bridged network from an instance is currently not supported. + +## Possible values + +This setting can have a boolean value (`true` or `false`). However, at this time, it can only be manually set to `true`, but not to `false`. + +The value of this setting depends on the value of [`local.bridged-network`](/reference/settings/local-bridged-network); that is, it varies dynamically according to the configured preferred network and the networks that have been added to the instance so far. + +## Examples + +`multipass set local.ultimate-grosbeak.bridged=true` + +If the instance `ultimate-grosbeak` was launched with the command `multipass launch --network eth0`, the result of `multipass get local.ultimate-grosbeak.bridged` will be `true` for as long as the value of `local.bridged-network` is `eth0`. + +If you run the command `multipass set local.bridged-network=eth1`, the result of `multipass get local.ultimate-grosbeak.bridged` will become `false`. At that point, you could run the command `multipass set local.ultimate-grosbeak.bridged=true` to bridge `ultimate-grosbeak` with `eth1`. + +### Bridged connection to a physical network interface + +On some platforms/backends, Multipass cannot connect instances directly to physical network interface controllers (NICs). In this case, Multipass offers to create a bridge/switch on the host connecting to that NIC. The instance is then connected to the bridge/switch, achieving the same effect as if it had been connected to the physical NIC directly. An instance that is indirectly connected with a physical NIC in this fashion is also considered to be bridged with that NIC by Multipass. + +For example, if the preferred network is `eth1` and the instance `ultimate-grosbeak` is connected with a bridge `br-eth1` that is linked with `eth1`, then `multipass get local.ultimate-grosbeak.bridged` will return `true`. + +## Default value + +`true` if the instance is bridged with the preferred network, `false` otherwise. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-instance-name-cpus.md b/docs/reference/settings/local-instance-name-cpus.md new file mode 100644 index 0000000000..39c705ce3e --- /dev/null +++ b/docs/reference/settings/local-instance-name-cpus.md @@ -0,0 +1,29 @@ +# local.\.cpus +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`launch`](/reference/command-line-interface/launch). + +## Key + +`local..cpus` + +where `` is the name of a Multipass instance. + +## Description + +The number of CPUs to simulate on the virtual machine. This establishes a limit on how many host threads the instance can simultaneously use, at most. + +## Possible values + +A positive integer number. Multipass does not impose an upper limit on the possible values, but the underlying backend may do so. + +## Examples + +`multipass set local.handsome-ling.cpus=4` + +## Default value + +The number of CPUs that the instance was launched with. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-instance-name-disk.md b/docs/reference/settings/local-instance-name-disk.md new file mode 100644 index 0000000000..af17f4fabe --- /dev/null +++ b/docs/reference/settings/local-instance-name-disk.md @@ -0,0 +1,42 @@ +# local.\.disk +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`launch`](/reference/command-line-interface/launch) + +## Key + +`local..disk` + +where `` is the name of a Multipass instance. + +## Description + +The size of the instance's disk. + +```{caution} +The disk size can only be increased. +Decreasing the disk size is not permitted since it could cause data loss and the VM might break. +``` + +## Allowed values + +A size no smaller than the current disk size. This size can be specified with a positive integer or decimal number, optionally followed by a unit. Any case variations of the following suffixes are accepted as units: + - B, to designate one byte. + - KiB, KB, or K, to designate 1024 bytes. + - MiB, MB, or M, to designate 1024 x 1024 = 1048576 bytes + - GiB, GB, or G, to designate 1024 x 1024 x 1024 = 1073741824 bytes + +[note type="information"] +Decimal bytes (e.g. 1.1B) are refused, unless specified with larger units (>= KiB), in which case the amount is floored (e.g. 1.2KiB is interpreted as 1228B, even though 1.2 x 1024 = 1228.8). +``` + +## Examples + +`multipass set local.handsome-ling.disk=7.5G` + +## Default value + +The size of the disk that the instance was launched with. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-instance-name-memory.md b/docs/reference/settings/local-instance-name-memory.md new file mode 100644 index 0000000000..951acffcc2 --- /dev/null +++ b/docs/reference/settings/local-instance-name-memory.md @@ -0,0 +1,45 @@ +# local.\.memory +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`launch`](/reference/command-line-interface/launch) + +## Key + +`local..memory` + +where `` is the name of a Multipass instance. + +## Description + +The amount of RAM that is allocated to the instance. + +[note type="information"] +Hypervisors may impose additional rounding on the total memory that is given to the instance. Furthermore, the value that is set here does not correspond exactly to the memory size that is available in userspace inside the instance (e.g. reported by `free -b`), because the guest kernel claims some for its own. Total memory can be inspected inside the instance with `lshw` (e.g. `sudo lshw -json -class memory`). +``` + +[note type="information"] +Memory on the host is only allocated as the instance uses it, not right away. Once used, it is not released until the instance is shutdown or restarted. +``` + +## Allowed values + +A positive memory size, specified with a positive integer or decimal number, optionally followed by a unit. Any case variations of the following suffixes are accepted as units: + - B, to designate one byte + - KiB, KB, or K, to designate 1024 bytes + - MiB, MB, or M, to designate 1024 x 1024 = 1048576 bytes + - GiB, GB, or G, to designate 1024 x 1024 x 1024 = 1073741824 bytes + +[note type="information"] +Decimal bytes (e.g. 1.1B) are refused, unless specified with larger units (>= KiB), in which case the amount is floored (e.g. 1.2KiB is interpreted as 1228B, even though 1.2 x 1024 = 1228.8). +``` + +## Examples + +`multipass set local.handsome-ling.memory=4G` + +## Default value + +The amount of memory that the instance was launched with. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-instance-name-snapshot-name-comment.md b/docs/reference/settings/local-instance-name-snapshot-name-comment.md new file mode 100644 index 0000000000..38cdbb09aa --- /dev/null +++ b/docs/reference/settings/local-instance-name-snapshot-name-comment.md @@ -0,0 +1,29 @@ +# local.\.\.comment +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`snapshot`](/reference/command-line-interface/snapshot) + +## Key + +`local...comment` + +Where `` is the name of a Multipass instance and `` is the current name of one of its snapshots. + +## Description + +An optional free piece of text that is associated with the snapshot. This can be used to describe the snapshot, recognize its role, or any other purpose. + +## Possible values + +Any string that your terminal can encode. + +## Examples + +`multipass set local.relative-lion.snaphot2.comment="Got it! 😏"` + +## Default value + +The comment that was assigned to the snapshot when it was taken. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-instance-name-snapshot-name-name.md b/docs/reference/settings/local-instance-name-snapshot-name-name.md new file mode 100644 index 0000000000..5be0f2ebc2 --- /dev/null +++ b/docs/reference/settings/local-instance-name-snapshot-name-name.md @@ -0,0 +1,29 @@ +# local.\.\.name +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`snapshot`](/reference/command-line-interface/snapshot), [Instance](/explanation/instance) + +## Key + +`local...name` + +where `` is the name of a Multipass instance and `` is the current name of one of its snapshots. + +## Description + +The name that identifies the snapshot in the context of its instance. Snapshot names cannot be repeated. + +## Possible values + +Any name that follows the same rules as [instance names](/t/28469#heading--Instance-name-format) and is not currently in use by another instance. + +## Examples + +`multipass set local.relative-lion.snaphot2.name=primed` + +## Default value + +The name that was assigned to the snapshot when it was taken. + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-passphrase.md b/docs/reference/settings/local-passphrase.md new file mode 100644 index 0000000000..943f89438a --- /dev/null +++ b/docs/reference/settings/local-passphrase.md @@ -0,0 +1,31 @@ +# local.passphrase +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`authenticate`](/reference/command-line-interface/authenticate) + +## Key + +`local.passphrase` + +## Description + +Passphrase used by clients requesting access to the Multipass service via the [`multipass authenticate`](/reference/command-line-interface/authenticate) command. + +The passphrase can be given directly in the command line; if omitted, the user will be prompted to enter it. + + + +## Possible values + +Any string + +## Examples + +`multipass set local.passphrase` + +## Default value + +Not set (expressed as `false` by `multipass get`) + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reference/settings/local-privileged-mounts.md b/docs/reference/settings/local-privileged-mounts.md new file mode 100644 index 0000000000..1161ffd40f --- /dev/null +++ b/docs/reference/settings/local-privileged-mounts.md @@ -0,0 +1,28 @@ +# local.privileged-mounts +> See also: [`get`](/reference/command-line-interface/get), [`set`](/reference/command-line-interface/set), [`mount`](/reference/command-line-interface/mount), [Mount](/explanation/mount) + +## Key + +`local.privileged-mounts` + +## Description + +Controls whether [`multipass mount`](/reference/command-line-interface/mount) is allowed. + +## Possible values + +Any case variations of `on`|`off`, `yes`|`no`, `1`|`0` or `true`|`false`. + +## Examples + +`multipass set local.privileged-mounts=Yes` + +## Default value + + - `true` on Linux and macOS + - `false` on Windows + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + diff --git a/docs/reuse/links.txt b/docs/reuse/links.txt new file mode 100644 index 0000000000..6b68da8429 --- /dev/null +++ b/docs/reuse/links.txt @@ -0,0 +1,36 @@ +.. _reStructuredText style guide: https://canonical-documentation-with-sphinx-and-readthedocscom.readthedocs-hosted.com/style-guide/ +.. _MyST style guide: https://canonical-documentation-with-sphinx-and-readthedocscom.readthedocs-hosted.com/style-guide-myst/ +.. _Read the Docs at Canonical: https://library.canonical.com/documentation/read-the-docs-at-canonical +.. _How to publish documentation on Read the Docs: https://library.canonical.com/documentation/publish-on-read-the-docs +.. _Example product documentation: https://canonical-example-product-documentation.readthedocs-hosted.com/ +.. wokeignore:rule=master +.. _`Sphinx configuration`: https://www.sphinx-doc.org/en/master/usage/configuration.html +.. wokeignore:rule=master +.. _`Sphinx extensions`: https://www.sphinx-doc.org/en/master/usage/extensions/index.html +.. wokeignore:rule=master +.. _`file-wide metadata`: https://www.sphinx-doc.org/en/master/usage/restructuredtext/field-lists.html +.. _`Furo documentation`: https://pradyunsg.me/furo/quickstart/ +.. _`Hiding Contents sidebar`: https://pradyunsg.me/furo/customisation/toc/ +.. _`Sphinx`: https://www.sphinx-doc.org/ +.. _woke documentation: https://docs.getwoke.tech/ignore +.. _Canonical Sphinx: https://github.com/canonical/canonical-sphinx +.. _change log: https://github.com/canonical/sphinx-docs-starter-pack/wiki/Change-log +.. _Open Graph: https://ogp.me/ +.. _manual import: https://readthedocs.com/dashboard/import/manual/ +.. _How to manually configure a Git repository integration: https://docs.readthedocs.io/en/stable/guides/setup/git-repo-manual.html +.. _reStructuredText: https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html +.. _Markdown: https://commonmark.org/ +.. _MyST: https://myst-parser.readthedocs.io/ +.. _Diátaxis: https://diataxis.fr/ +.. _Pa11y: https://pa11y.org/ +.. _Pa11y readme: https://github.com/pa11y/pa11y#command-line-configuration +.. _woke: https://github.com/get-woke/woke +.. _woke User Guide: https://docs.getwoke.tech/usage/#file-globs +.. _More useful markup: https://canonical-documentation-with-sphinx-and-readthedocscom.readthedocs-hosted.com/style-guide/#more-useful-markup +.. _Vale: https://vale.sh/ +.. _Vale rules: https://github.com/canonical/praecepta +.. _Web Content Accessibility Guidelines (WCAG) 2.2: https://www.w3.org/TR/WCAG22/ +.. _Level AA conformance: https://www.w3.org/WAI/WCAG2AA-Conformance + +.. SHORTCUTS +.. |RST| replace:: :abbr:`reST (reStructuredText)` diff --git a/docs/tutorial.md b/docs/tutorial.md new file mode 100644 index 0000000000..b4f3af2916 --- /dev/null +++ b/docs/tutorial.md @@ -0,0 +1,689 @@ +# Tutorial + + +Multipass is a flexible and powerful tool that can be used for many purposes. In its simplest form, you can use it to quickly create and destroy Ubuntu VMs (instances) on any host machine. But you can also use Multipass to build a local mini-cloud on your laptop, to test and develop multi-instance or container-based cloud applications. + +This tutorial will help you understand how Multipass works, and the skills you need to use its main features. + +## Install Multipass + +Multipass is available for Linux, macOS and Windows. To install it on the OS of your choice, please follow the instructions provided in [How to install Multipass](/how-to-guides/install-multipass). + +[note type="information"] +Select the tab corresponding to your operating system (e.g. Linux) to display the relevant content in each section. Your decision will stick until you select another OS from the drop-down menu. +``` + +## Create and use a basic instance + +[tabs] + +[tab version="Linux"] + +Start Multipass from the application launcher. In Ubuntu, press the super key and type "Multipass", or find Multipass in the Applications panel on the lower left of the desktop. + +![|800x450](https://assets.ubuntu.com/v1/949aa05e-mp-linux-1.png) + +After launching the application, you should see the Multipass tray icon on the upper right section of the screen. + +![|688x52](https://assets.ubuntu.com/v1/5ec546da-mp-linux-2.png) + +Click on the Multipass icon and select **Open Shell**. + +![|286x274](https://assets.ubuntu.com/v1/3ecc5e7d-mp-linux-2a.png) + +Clicking this button does many things in the background: +* It creates a new virtual machine (instance) named `primary`, with 1GB of RAM, 5GB of disk, and 1 CPU. See also: [Primary instance](/t/28469#primary-instance). +* It installs the most recent Ubuntu LTS release on that instance. +* It mounts your `$HOME` directory in the instance. +* It opens a shell to the instance, announced by the command prompt `ubuntu@primary`. + + + +```{caution} +If your local home folder is encrypted using ` fscrypt` and you are having trouble accessing its contents when it is automatically mounted inside your primary instance, see: [Mount an encrypted home folder](/how-to-guides/troubleshoot/mount-an-encrypted-home-folder). +``` + +You can see elements of this in the printout below: + +```plain +Launched: primary +Mounted '/home/' into 'primary:Home' +Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-57-generic x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + System information as of Thu Jan 26 08:06:22 PST 2023 + + System load: 0.0 Processes: 95 + Usage of /: 30.2% of 4.67GB Users logged in: 0 + Memory usage: 21% IPv4 address for ens3: 10.110.66.242 + Swap usage: 0% + + * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s + just raised the bar for easy, resilient and secure K8s cluster deployment. + + https://ubuntu.com/engage/secure-kubernetes-at-the-edge + +0 updates can be applied immediately. + + +The list of available updates is more than a week old. +To check for new updates run: sudo apt update + +ubuntu@primary:~$ +``` + +Let's test it. As you've just learnt, the previous step automatically mounted your `$HOME` directory in the instance. Use this to share data with your instance. More concretely, create a new folder called `Multipass_Files` in your `$HOME` directory: + +![|720x405](https://assets.ubuntu.com/v1/fbfc8304-mp-linux-3.png) + +As you can see, a `README.md` file has been added to the shared folder. Check for the folder and read the file from your new instance: + +```plain +cd ./Home/Multipass_Files/ +cat README.md +``` + +Sample output: + +```plain +## Shared Folder + +This folder could be a great place to keep files that need to be accessed by both your host machine and Ubuntu VM! +``` + +[/tab] + +[tab version="macOS"] + +Start Multipass from the application launcher. In macOS, open the application launcher, type "Multipass", and launch the application. + +**![|720x451](https://assets.ubuntu.com/v1/a4ff7fad-mp-macos-1.png)** + +After launching the application, you should see the Multipass tray icon in the upper right section of the screen. + +**![|684x48](https://assets.ubuntu.com/v1/42bb4ccb-mp-macos-2.png)** + +Click on the Multipass icon and select **Open Shell**. + +**![|304x352](https://assets.ubuntu.com/v1/eb92083a-mp-macos-3.png)** + +Clicking this button does many things in the background: + +* It creates a new virtual machine (instance) named "primary", with 1GB of RAM, 5GB of disk, and 1 CPU. +* It installs the most recent Ubuntu LTS release on that instance. Last, it mounts your `$HOME` directory in the instance. +* It opens a shell to the instance, announced by the command prompt `ubuntu@primary`. + +You can see elements of this in the printout below: + +```plain +Launched: primary +Mounted '/home/' into 'primary:Home' +Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-57-generic x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + System information as of Thu Jan 26 21:15:05 UTC 2023 + + System load: 0.72314453125 Processes: 105 + Usage of /: 29.8% of 4.67GB Users logged in: 0 + Memory usage: 20% IPv4 address for ens3: 192.168.64.5 + Swap usage: 0% + + +0 updates can be applied immediately. + + +The list of available updates is more than a week old. +To check for new updates run: sudo apt update + +ubuntu@primary:~$ +``` + +Let’s test it out. As you've just learnt, the previous step automatically mounted your `$HOME` directory in the instance. Use this to share data with your instance. More concretely, create a new folder called `Multipass_Files` in your `$HOME` directory. + +**![|720x329](https://assets.ubuntu.com/v1/5867fb49-mp-macos-4.png)** + +As you can see, a `README.md` file has been added to the shared folder. Check for the folder and read the file from your new instance: + +```plain +ubuntu@primary:~$ cd ./Home/Multipass_Files/ +ubuntu@primary:~/Home/Multipass_Files$ cat README.md +## Shared Folder + +This folder could be a great place to keep files that need to be accessed by both your host machine and Ubuntu VM! + +ubuntu@primary:~/Home/Multipass_Files$ +``` + +[/tab] + +[tab version="Windows"] + +Start Multipass from the application launcher. Press the Windows key and type "Multipass", then launch the application. + +**![|720x625](https://assets.ubuntu.com/v1/50b86111-mp-windows-1.png)** + +After launching the application, you should see the Multipass tray icon in the lower right section of the screen (you may need to click on the small arrow located there). + +**![|429x221](https://assets.ubuntu.com/v1/8c28e82a-mp-windows-2.png)** + +Click on the Multipass icon and select **Open Shell**. + +**![|423x241](https://assets.ubuntu.com/v1/33a6bf4d-mp-windows-3.png)** + +Clicking this button does many things in the background. First, it creates a new virtual machine (instance) named "primary", with 1GB of RAM, 5GB of disk, and 1 CPU. Second, it installs the most recent Ubuntu LTS release on that instance. Third, it mounts your `$HOME` directory in the instance. Last, it opens a shell to the instance, announced by the command prompt `ubuntu@primary`. + +You can see elements of this in the printout below: + +```plain +Launched: primary +Mounted '/home/' into 'primary:Home' +Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-57-generic x86_64) + + * Documentation: https://help.ubuntu.com + * Management: https://landscape.canonical.com + * Support: https://ubuntu.com/advantage + + System information as of Thu Jan 26 08:06:22 PST 2023 + + System load: 0.0 Processes: 95 + Usage of /: 30.2% of 4.67GB Users logged in: 0 + Memory usage: 21% IPv4 address for ens3: 10.110.66.242 + Swap usage: 0% + + * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s + just raised the bar for easy, resilient and secure K8s cluster deployment. + + https://ubuntu.com/engage/secure-kubernetes-at-the-edge + +0 updates can be applied immediately. + + +The list of available updates is more than a week old. +To check for new updates run: sudo apt update + +ubuntu@primary:~$ +``` + +Let’s test it out. As you've just learnt, the previous step automatically mounted your `$HOME` directory in the instance. Try out a few Linux commands to see what you’re working with. + +```plain +ubuntu@primary:~$ free + total used free shared buff/cache available +Mem: 925804 203872 362484 916 359448 582120 +Swap: 0 0 0 +ubuntu@primary:~$ df +Filesystem 1K-blocks Used Available Use% Mounted on +tmpfs 92584 912 91672 1% /run +/dev/sda1 4893836 1477300 3400152 31% / +tmpfs 462900 0 462900 0% /dev/shm +tmpfs 5120 0 5120 0% /run/lock +/dev/sda15 106858 5329 101529 5% /boot/efi +tmpfs 92580 4 92576 1% /run/user/1000 +:C:/Users/Scott 1048576000 0 1048576000 0% /home/ubuntu/Home +``` + +[/tab] + +[/tabs] + +Congratulations, you've got your first instance! + +This instance is great for when you just need a quick Ubuntu VM, but let's say you want a more customised instance, how can you do that? Multipass has you covered there too. + +[details = "Optional Exercises"] +Exercise 1: +When you select Open Shell, what happens in the background is the equivalent of the CLI commands `multipass launch –name primary` followed by `multipass shell`. Open a terminal and try `multipass shell` (if you didn't follow the steps above, you will have to run the `launch` command first). + +Exercise 2: +In Multipass, an instance with the name "primary" is privileged. That is, it serves as the default argument of `multipass shell` among other capabilities. In different terminal instances, check `multipass shell primary` and `multipass shell`. Both commands should give the same result. +[/details] + +## Create a customised instance + +Multipass has a great feature to help you get started with creating customised instances. Open a terminal and run the `multipass find` command. The result shows a list of all images you can currently launch through Multipass. + +```plain +$ multipass find +Image Aliases Version Description +snapcraft:core18 18.04 20201111 Snapcraft builder for Core 18 +snapcraft:core20 20.04 20210921 Snapcraft builder for Core 20 +snapcraft:core22 22.04 20220426 Snapcraft builder for Core 22 +snapcraft:devel 20230126 Snapcraft builder for the devel series +core core16 20200818 Ubuntu Core 16 +core18 20211124 Ubuntu Core 18 +core20 20230119 Ubuntu Core 20 +core22 20230119 Ubuntu Core 22 +18.04 bionic 20230112 Ubuntu 18.04 LTS +20.04 focal 20230117 Ubuntu 20.04 LTS +22.04 jammy,lts 20230107 Ubuntu 22.04 LTS +22.10 kinetic 20230112 Ubuntu 22.10 +daily:23.04 devel,lunar 20230125 Ubuntu 23.04 +appliance:adguard-home 20200812 Ubuntu AdGuard Home Appliance +appliance:mosquitto 20200812 Ubuntu Mosquitto Appliance +appliance:nextcloud 20200812 Ubuntu Nextcloud Appliance +appliance:openhab 20200812 Ubuntu openHAB Home Appliance +appliance:plexmediaserver 20200812 Ubuntu Plex Media Server Appliance +anbox-cloud-appliance latest Anbox Cloud Appliance +charm-dev latest A development and testing environment for charmers +docker 0.4 A Docker environment with Portainer and related tools +jellyfin latest Jellyfin is a Free Software Media System that puts you in control of managing and streaming your media. +minikube latest minikube is local Kubernetes +``` + +Launch an instance running Ubuntu 22.10 ("Kinetic Kudu") by typing the `multipass launch kinetic` command. + +[tabs] + +[tab version="Linux"] + +Now, you have an instance running and it has been named randomly by Multipass. In this case, it has been named "coherent-trumpetfish". + +```plain +$ multipass launch kinetic +Launched: coherent-trumpetfish +``` + +You can check some basic info about your new instance by running the following command: + +`multipass exec coherent-trumpetfish -- lsb_release -a` + +This tells multipass to run the command `lsb_release -a` on the "coherent-trumpetfish" instance. + +```plain +$ multipass exec coherent-trumpetfish -- lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 22.10 +Release: 22.10 +Codename: kinetic +``` + +Perhaps after using this instance for a while, you decide that what you really need is the latest LTS version of Ubuntu, with a more informative name and a little more memory and disk. You can delete the "coherent-trumpetfish" instance by running the following command: + +`multipass delete coherent-trumpetfish` + +You can now launch the type of instance you need by running this command: + +`multipass launch lts --name ltsInstance --memory 2G --disk 10G --cpus 2` + +[/tab] + +[tab version="macOS"] + +Now, you have an instance running and it has been named randomly by Multipass. In this case, it has been named "breezy-liger". + +```plain +$ multipass launch kinetic +Launched: breezy-liger +``` + +You can check some basic info about your new instance by running the following command: + +`multipass exec breezy-liger -- lsb_release -a` + +This tells Multipass to run the command `lsb_release -a` on the “breezy-liger” instance. + +```plain +$ multipass exec breezy-liger -- lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 22.10 +Release: 22.10 +Codename: kinetic +``` + +Perhaps after using this instance for a while, you decide that what you really need is the latest LTS version of Ubuntu, with a more informative name and a little more memory and disk. You can delete the "breezy-liger" instance by running the following command: + +`multipass delete breezy-liger` + +You can now launch the type of instance you need by running this command: + +`multipass launch lts --name ltsInstance --memory 2G --disk 10G --cpus 2` + +[/tab] + +[tab version="Windows"] + +Now, you have an instance running and it has been named randomly by Multipass. In this case, it has been named "decorous-skate". + +```plain +C:\WINDOWS\system32> multipass launch kinetic +Launched: decorous-skate +``` + +You can check some basic info about your new instance by running the following command: + +`multipass exec decorous-skate -- lsb_release -a` + +This tells Multipass to run the command `lsb_release -a` on the “decorous-skate” instance. + +```plain +C:\WINDOWS\system32> multipass exec decorous-skate -- lsb_release -a +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 22.10 +Release: 22.10 +Codename: kinetic +``` + +Perhaps after using this instance for a while, you decide that what you really need is the latest LTS version of Ubuntu, with a more informative name and a little more memory and disk. You can delete the "decorous-skate" instance by running the following command: + +`multipass delete decorous-skate` + +You can now launch the type of instance you need by running this command: + +`multipass launch lts --name ltsInstance --memory 2G --disk 10G --cpus 2` + +[/tab] + +[/tabs] + +## Manage instances + +You can confirm that the new instance has the specs you need by running `multipass info ltsInstance`. + +[tabs] + +[tab version="Linux"] + +```plain +$ multipass info ltsInstance +Name: ltsInstance +State: Running +IPv4: 10.110.66.139 +Release: Ubuntu 22.04.1 LTS +Image hash: 3100a27357a0 (Ubuntu 22.04 LTS) +CPU(s): 2 +Load: 1.11 0.36 0.12 +Disk usage: 1.4GiB out of 9.5GiB +Memory usage: 170.4MiB out of 1.9GiB +Mounts: -- +``` + +You've created and deleted quite a few instances. It is time to run `multipass list` to see the instances you currently have. + +```plain +$ multipass list +Name State IPv4 Image +primary Running 10.110.66.242 Ubuntu 22.04 LTS +coherent-trumpetfish Deleted -- Not Available +ltsInstance Running 10.110.66.139 Ubuntu 22.04 LTS +``` + +The result shows that you have two instances running, the "primary" instance and the LTS machine with customised specs. The "coherent-trumpetfish" instance is still listed, but its state is "Deleted". You can recover this instance by running `multipass recover coherent-trumpetfish`. But for now, delete the instance permanently by running `multipass purge`. Then run `multipass list` again to confirm that the instance has been permanently deleted. + +```plain +$ multipass list +Name State IPv4 Image +primary Running 10.110.66.242 Ubuntu 22.04 LTS +ltsInstance Running 10.110.66.139 Ubuntu 22.04 LTS +``` + + +[/tab] + +[tab version="macOS"] + +```plain +$ multipass info ltsInstance +Name: ltsInstance +State: Running +IPv4: 192.168.64.3 +Release: Ubuntu 22.04.1 LTS +Image hash: 3100a27357a0 (Ubuntu 22.04 LTS) +CPU(s): 2 +Load: 1.55 0.44 0.15 +Disk usage: 1.4GiB out of 9.5GiB +Memory usage: 155.5MiB out of 1.9GiB +Mounts: -- +``` + +You've created and deleted quite a few instances. It is time to run `multipass list` to see the instances you currently have. + +```plain +$ multipass list +Name State IPv4 Image +primary Running 192.168.64.5 Ubuntu 22.04 LTS +breezy-liger Deleted -- Not Available +ltsInstance Running 192.168.64.3 Ubuntu 22.04 LTS +``` + +The result shows that you have two instances running, the "primary" instance and the LTS machine with customised specs. The "breezy-liger" instance is still listed, but its state is "Deleted". You can recover this instance by running `multipass recover breezy-liger`. But for now, delete the instance permanently by running `multipass purge`. Then run `multipass list` again to confirm that the instance has been permanently deleted. + +```plain +$ multipass list +Name State IPv4 Image +primary Running 192.168.64.5 Ubuntu 22.04 LTS +ltsInstance Running 192.168.64.3 Ubuntu 22.04 LTS +``` + +[/tab] + +[tab version="Windows"] + +```plain +C:\WINDOWS\system32> multipass info ltsInstance +Name: ltsInstance +State: Running +IPv4: 172.22.115.152 +Release: Ubuntu 22.04.1 LTS +Image hash: 3100a27357a0 (Ubuntu 22.04 LTS) +CPU(s): 2 +Load: 1.11 0.36 0.12 +Disk usage: 1.4GiB out of 9.5GiB +Memory usage: 170.4MiB out of 1.9GiB +Mounts: -- +``` + +You've created and deleted quite a few instances. It is time to run `multipass list` to see the instances you currently have. + +```plain +C:\WINDOWS\system32> multipass list +Name State IPv4 Image +primary Running 10.110.66.242 Ubuntu 22.04 LTS +decorous-skate Deleted -- Not Available +ltsInstance Running 172.22.115.152 Ubuntu 22.04 LTS +``` + +The result shows that you have two instances running, the "primary" instance and the LTS machine with customised specs. The "decorous-skate" instance is still listed, but its state is "Deleted". You can recover this instance by running `multipass recover decorous-skate`. But for now, delete the instance permanently by running `multipass purge`. Then run `multipass list` again to confirm that the instance has been permanently deleted. + +```plain +C:\WINDOWS\system32> multipass list +Name State IPv4 Image +primary Running 10.110.66.242 Ubuntu 22.04 LTS +ltsInstance Running 172.22.115.152 Ubuntu 22.04 LTS +``` + +[/tab] + +[/tabs] + +You've now seen a few ways to create, customise, and delete an instance. It is time to put those instances to work! + +## Put your instances to use + +Let's see some practical examples of what you can do with your Multipass instances: + +* [Run a simple web server](#run-a-simple-web-server) +* [Launch from a Blueprint to run Docker containers](#launch-from-a-blueprint-to-run-docker-containers) + +### Run a simple web server + +One way to put a Multipass instance to use is by running a local web server in it. + +Return to your customised LTS instance. Take note of its IP address, which was revealed when you ran `multipass list`. Then run `multipass shell ltsInstance` to open a shell in the instance. + +From the shell, you can run: + +``` +sudo apt update + +sudo apt install apache2 +``` + +Open a browser and type in the IP address of your instance into the address bar. You should now see the default Apache homepage. + +[tabs] + +[tab version="Linux"] +![|720x545](https://assets.ubuntu.com/v1/e106f7f9-mp-linux-4.png) +[/tab] + +[tab version="macOS"] +![|720x545](https://assets.ubuntu.com/v1/e106f7f9-mp-macos-5.png) +[/tab] + +[tab version="Windows"] +![|720x545](https://assets.ubuntu.com/v1/e106f7f9-mp-windows-12.png) +[/tab] + +[/tabs] + +Just like that, you've got a web server running in a Multipass instance! + +You can use this web server locally for any kind of local development or testing. However, if you want to access this web server from the internet (for instance, a different computer), you need an instance that is exposed to the external network. + +### Launch from a Blueprint to run Docker containers + +Some environments require a lot of configuration and setup. Multipass Blueprints are instances with a deep level of customization. For example, the Docker Blueprint is a pre-configured Docker environment with a Portainer container already running. + +You can launch an instance using the Docker Blueprint by running `multipass launch docker --name docker-dev`. + +Once that's done, run `multipass info docker-dev` to note down the IP of the new instance. + +[tabs] + +[tab version="Linux"] + +```plain +$ multipass launch docker --name docker-dev +Launched: docker-dev +$ multipass info docker-dev +Name: docker-dev +State: Running +IPv4: 10.115.5.235 + 172.17.0.1 +Release: Ubuntu 22.04.1 LTS +Image hash: 3100a27357a0 (Ubuntu 22.04 LTS) +CPU(s): 2 +Load: 1.50 2.21 1.36 +Disk usage: 2.6GiB out of 38.6GiB +Memory usage: 259.7MiB out of 3.8GiB +Mounts: -- +``` + +Copy the IP address starting with "10" and paste it into your browser, then add a colon and the portainer default port, 9000. It should look like this: 10.115.5.235:9000. This will take you to the Portainer login page where you can set a username and password. + +![|720x543](https://assets.ubuntu.com/v1/75a164a1-mp-linux-5.png) + +From there, select **Local** to manage a local Docker environment. + +![|720x601](https://assets.ubuntu.com/v1/ee3ff308-mp-linux-6.png) + +Inside the newly selected local Docker environment, locate the sidebar menu on the page and click on **app templates**, then select **NGINX**. + +![|720x460](https://assets.ubuntu.com/v1/86be3eae-mp-linux-7.png) + +From the Portainer dashboard, you can see the ports available on nginx. To verify that you have nginx running in a Docker container inside Multipass, open a new web page and paste the IP address of your instance followed by one of the port numbers. + +![|720x465](https://assets.ubuntu.com/v1/25585a03-mp-linux-8.png) + +[/tab] + +[tab version="macOS"] + +```plain +$ multipass launch docker --name docker-dev +Launched: docker-dev +$ multipass info docker-dev +Name: docker-dev +State: Running +IPv4: 10.115.5.235 + 172.17.0.1 +Release: Ubuntu 22.04.1 LTS +Image hash: 3100a27357a0 (Ubuntu 22.04 LTS) +CPU(s): 2 +Load: 1.40 0.64 0.25 +Disk usage: 2.5GiB out of 38.6GiB +Memory usage: 236.4MiB out of 3.8GiB +Mounts: -- +``` + +Copy the IP address starting with "10" and paste it into your browser, then add a colon and the portainer default port, 9000. It should look like this: 10.115.5.235:9000. This will take you to the Portainer login page where you can set a username and password. + +![|720x543](https://assets.ubuntu.com/v1/75a164a1-mp-macos-6.png) + +From there, select **Local** to manage a local Docker environment. + +![|720x601](https://assets.ubuntu.com/v1/ee3ff308-mp-macos-7.png) + +Inside the newly selected local Docker environment, locate the sidebar menu on the page and click on **app templates**, then select **NGINX**. + +![|720x460](https://assets.ubuntu.com/v1/86be3eae-mp-macos-8.png) + +From the Portainer dashboard, you can see the ports available on nginx. To verify that you have nginx running in a Docker container inside Multipass, open a new web page and paste the IP address of your instance followed by one of the port numbers. + +![|720x465](https://assets.ubuntu.com/v1/25585a03-mp-macos-9.png) + +[/tab] + +[tab version="Windows"] + +```plain +C:\WINDOWS\system32> multipass launch docker --name docker-dev +Launched: docker-dev +C:\WINDOWS\system32> multipass info docker-dev +Name: docker-dev +State: Running +IPv4: 10.115.5.235 + 172.17.0.1 +Release: Ubuntu 22.04.1 LTS +Image hash: 3100a27357a0 (Ubuntu 22.04 LTS) +CPU(s): 2 +Load: 0.04 0.17 0.09 +Disk usage: 2.5GiB out of 38.6GiB +Memory usage: 283.3MiB out of 3.8GiB +Mounts: -- +``` + +Copy the IP address starting with "10" and paste it into your browser, then add a colon and the portainer default port, 9000. It should look like this: 10.115.5.235:9000. This will take you to the Portainer login page where you can set a username and password. + +![|720x601](https://assets.ubuntu.com/v1/75a164a1-mp-windows-14.png) + +From there, select **Local** to manage a local Docker environment. + +![|720x460](https://assets.ubuntu.com/v1/ee3ff308-mp-windows-15.png) + +Inside the newly selected local Docker environment, locate the sidebar menu on the page and click on **app templates**, then select **NGINX**. + +![](https://assets.ubuntu.com/v1/86be3eae-mp-windows-16.png) + +From the Portainer dashboard, you can see the ports available on nginx. To verify that you have nginx running in a Docker container inside Multipass, open a new web page and paste the IP address of your instance followed by one of the port numbers. + +![|720x465](https://assets.ubuntu.com/v1/f0b28200-mp-windows-17.png) + +[/tab] + +[/tabs] + +## Next steps + +Congratulations! You can now use Multipass proficiently. + +There's more to learn about Multipass and its capabilities. Check out our [How-to guides](/how-to-guides/how-to-guides) for ideas and help with your project. In our [Explanation](/explanation/explanation) and [Reference](/reference/reference) pages you can find definitions of key concepts, a complete CLI command reference, settings options and more. + +Join the discussion on the [Multipass forum](https://discourse.ubuntu.com/c/multipass/) and let us know what you are doing with your instances! + +--- + +*Errors or typos? Topics missing? Hard to read? Let us know or open an issue on GitHub.* + +--- + +**Contributors:** @nhart, @saviq, @townsend, @andreitoterman, @tmihoc, @luisp, @ricab, @sharder996, @georgeliaojia, @mscho7969, @itecompro, @mr-cal, @sally-makin, @gzanchi, @bagustris , @pitifulpete