Skip to content

Commit

Permalink
added windows install doc
Browse files Browse the repository at this point in the history
  • Loading branch information
hellt committed Nov 30, 2024
1 parent f7b86a8 commit 092584e
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/zsh/.p10k.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
local magenta='5'
local cyan='6'
local white='7'
local darkgreen='#23CE6B'
local darkgreen='#386641'

# Left prompt segments.
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
Expand Down
41 changes: 14 additions & 27 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ To install all components at once, run the following command on any of the suppo
curl -sL https://containerlab.dev/setup | sudo -E bash -s "all"
```

Complete installation and enable sudo-less `docker` command execution please run `newgrp docker` or logout and log back in.
To complete installation and enable sudo-less `docker` command execution, please run `newgrp docker` or logout and log back in.

<!-- --8<-- [end:quick-setup-script-cmd] -->

Expand Down Expand Up @@ -181,6 +181,16 @@ yum install https://github.com/srl-labs/containerlab/releases/download/v0.7.0/co
///
The package installer will put the `containerlab` binary in the `/usr/bin` directory as well as create the `/usr/bin/clab -> /usr/bin/containerlab` symlink. The symlink allows the users to save on typing when they use containerlab: `clab <command>`.

## Windows

Containerlab runs on Windows powered by Windows Subsystem Linux (aka WSL), where you can run Containerlab directly or in a Devcontainer. Open up [Containerlab on Windows](windows.md) documentation for more details.

## Apple macOS

Running containerlab on macOS is possible both on ARM (M1/M2/M3/etc) and Intel chipsets. For a long time, we had many caveats around M-chipsets on Macs, but with the introduction of ARM64-native NOSes like Nokia SR Linux and Arista cEOS, powered by Rosetta emulation for x86_64-based NOSes, it is now possible to run containerlab on ARM-based Macs.

Since we wanted to share our experience with running containerlab on macOS in details, we have created a separate - [Containerlab on macOS](macos.md) - guide.

## Container

Containerlab is also available in a container packaging. The latest containerlab release can be pulled with:
Expand Down Expand Up @@ -244,31 +254,9 @@ tar -zxvf /tmp/clab.tar.gz -C /etc/containerlab
mv /etc/containerlab/containerlab /usr/bin && chmod a+x /usr/bin/containerlab
```

## Windows Subsystem Linux (WSL)

Containerlab [runs](https://twitter.com/ntdvps/status/1380915270328401922) on WSL, but you need to [install docker-ce](https://docs.docker.com/engine/install/) inside the WSL2 linux system instead of using Docker Desktop[^2].

If you are running Ubuntu/Debian as your WSL2 machine, you can use the [quick setup this script](https://github.com/srl-labs/containerlab/blob/main/utils/quick-setup.sh) to install docker-ce.

```bash
curl -L https://containerlab.dev/setup | sudo bash -s "install-docker" | \
```

Once installed, issue `sudo service docker start` to start the docker service inside WSL2 machine.

/// details | Running VM-based routers inside WSL
In Windows 11 with WSL2 it is now possible to [enable KVM support](https://serverfault.com/a/1115773/351978). Let us know if that worked for you in our [Discord](community.md).
///

## Apple macOS

Running containerlab on macOS is possible both on ARM (M1/M2/M3/etc) and Intel chipsets. For a long time, we had many caveats around M-chipsets on Macs, but with the introduction of ARM64-native NOSes like Nokia SR Linux and Arista cEOS, powered by Rosetta emulation for x86_64-based NOSes, it is now possible to run containerlab on ARM-based Macs.

Since we wanted to share our experience with running containerlab on macOS in details, we have created a separate - [Containerlab on macOS](macos.md) - guide.

## Upgrade

To upgrade `containerlab` to the latest available version issue the following command[^3]:
To upgrade `containerlab` to the latest available version issue the following command[^2]:

```
sudo -E containerlab version upgrade
Expand Down Expand Up @@ -337,6 +325,5 @@ or more globally:
sudo setsebool -P selinuxuser_execmod 1
```

[^1]: Most containerized NOS will require >1 vCPU. RAM size depends on the lab size. Architecture: AMD64. IPv6 should not be disabled in the kernel.
[^2]: No need to uninstall Docker Desktop, just make sure that it is not integrated with WSL2 machine that you intend to use with containerlab. Moreover, you can make it even work with Docker Desktop with a [few additional steps](https://twitter.com/networkop1/status/1380976461641834500/photo/1), but installing docker-ce into the WSL maybe more intuitive.
[^3]: only available if installed from packages
[^1]: Most containerized NOS will require >1 vCPU. RAM size depends on the lab size. IPv6 should not be disabled in the kernel.
[^2]: only available if installed from packages
112 changes: 112 additions & 0 deletions docs/windows.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
---
comments: true
hide:
- navigation
---

# Containerlab on Windows

By leveraging the [Windows Subsystem Linux (aka WSL)](https://learn.microsoft.com/en-us/windows/wsl/) you can run Containerlabs on Windows almost like on Linux. WSL allows Windows users to run a lightweight Linux VM inside Windows, and we can leverage this to run containerlab.

There are two primary ways of running containerlab on Windows:

1. Running containerlab directly in the WSL VM.
2. Running containerlab inside a [Devcontainer](https://code.visualstudio.com/docs/devcontainers/containers) inside WSL.

We will cover both of these ways in this document, but first let's quickly go over the WSL setup.

/// admonition | Windows and WSL version
The following instructions were tested on Windows 11 and WSL2. On Windows 10 some commands may be different, but the general idea should be the same.
///

## Setting up WSL

WSL takes the central role in running containerlabs on Windows. Luckily, setting up WSL is very easy, and there are plenty of resources online from blogs to YT videos explaining the bits and pieces. Here we will provide some CLI-centric[^1] instructions that were executed on Windows 11.

First things first, open up a terminal and list the running WSL virtual machines and their versions:

```bash
wsl -l -v
```

<div class="embed-result">
```{.text .no-select .no-copy}
NAME STATE VERSION
* Ubuntu Running 2
```
</div>

On this system we already have a WSL VM with Ubuntu OS running, which was created when we installed WSL on Windows. If instead of a list of WSL VMs you get an error, you need to install WSL first:

```bash title="Installing WSL on Windows 11"
wsl --install
```

Installing WSL on Windows 11 will by default install the Ubuntu distribution. While it is perfectly fine to use it, we prefer Debian, so let's remove Ubuntu and install Debian instead:

```bash title="Removing Ubuntu and installing Debian"
wsl --unregister Ubuntu #(1)!
wsl --install -d Debian #(1)!
```

1. Unregistering a WSL VM will remove the VM. You should reference a WSL instance by the name you saw in the `wsl -l -v` command.
2. Installing a new WSL system will prompt you to choose a username and password.

Once the installation is complete, you will enter the WSL shell, which is a regular Linux shell[^2]. Congratulations, you have a working WSL system that can run containerlab.

## Installing docker and containerlab on WSL

Now that we have a working WSL system, we can install docker and containerlab on it like we would on any Linux system.

/// danger | WSL2 and Docker Desktop
If you have Docker Desktop[^3] installed on your Windows system, you need to ensure that it is not enabled for the WSL VM that we intend to use for containerlabs.
To check that your WSL system is "free" from Docker Desktop integration, run `sudo docker version` command and ensure that you have an error message saying that `docker` command is not found.

Check Docker Desktop settings to see how to disable Docker Desktop integration with WSL2 if the above command **does not** return an expected error.
///

We are going to use the [quick setup script](install.md#quick-setup) to install docker and containerlab, but since this script uses `curl`, we need to install it first:

```bash
sudo apt update && sudo apt -y install curl
```

and then run the quick setup script:

--8<-- "docs/install.md:quick-setup-script-cmd"

Now you should be able to run the `docker version` command and see the version of docker installed. That was easy, wasn't it?

The installation script also installs containerlab, so you can run `clab version` to see the version of containerlab installed. This means that containerlab is installed in the WSL VM and you can run containerlabs in a normal way, like you would on Linux.

/// details | Running VM-based routers inside WSL?
type: subtle-question
In Windows 11 with WSL2 it is now possible to [enable KVM support](https://serverfault.com/a/1115773/351978). Let us know if that worked for you in our [Discord](community.md).
///

## Devcontainer

Another convenient option to run containerlab on Windows (and [macOS](macos.md#devcontainer)) is to use the [Devcontainer](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers) feature that works great with VS Code and many other IDE's.

A development container (or devcontainer) allows you to use a container as a full-featured development environment. By creating the `devcontainer.json`[^4] file, you define the development environment for your project. Containerlab project maintains a set of pre-built multi-arch devcontainer images that you can use to run containerlabs.
It was initially created to power [containerlab in codespaces](manual/codespaces.md), but it is a perfect fit for running containerlab on a **wide range of OSes** such as macOS and Windows.

Since the devcontainer works exactly the same way on Windows and macOS, [please refer to the macOS](macos.md#devcontainer) section for the detailed documentation and a video walkthrough.

[^1]: If you don't have a decent terminal emulator on Windows, install "Windows Terminal" from the Microsoft Store.
[^2]: The kernel and distribution parameters can be checked as follows:

```bash
roman@Win11:~$ uname -a
Linux LAPTOP-H6R3238F 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 GNU/Linux
```

```bash
roman@Win11:~$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
```

[^3]: Or any other desktop docker solution like Rancher Desktop, Podman Desktop, etc.
[^4]: Follows the devcontainer [specification](https://containers.dev/)

0 comments on commit 092584e

Please sign in to comment.