Develop on Ubuntu 24.04 with Podman: Difference between revisions
Created page with "= Visual Studio Code with Podman on a Fresh Ubuntu 24.04 VM = This guide explains exactly how to set up **Visual Studio Code** (VS Code) with **Podman** on a clean installation of **Ubuntu 24.04 LTS** inside a virtual machine, and how to build and run the [https://github.com/MauiGtk/maui-docker maui-docker] project locally inside a Dev Container. == 1. Prepare the System == After installing Ubuntu 24.04, open a terminal and install the required packages: <syntaxhighl..." |
|||
| (17 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
= Visual Studio Code with Podman on a Fresh Ubuntu 24.04 VM = | = Visual Studio Code with Podman on a Fresh Ubuntu 24.04 VM = | ||
This guide explains exactly how to set up | This guide explains exactly how to set up Visual Studio Code (VS Code) with Podman on a clean installation of Ubuntu 24.04 LTS inside a virtual machine, and how to build and run the [https://github.com/MauiGtk/maui-docker maui-docker] project locally inside a Dev Container. | ||
== 1. Prepare the System == | == 1. Prepare the System == | ||
After installing Ubuntu 24.04, open a terminal and install the required packages: | After installing Ubuntu 24.04, open a terminal and install the required packages:<syntaxhighlight lang="bash">sudo apt update | ||
<syntaxhighlight lang="bash"> | |||
sudo apt update | |||
sudo apt install -y podman podman-docker uidmap curl git x11-apps | sudo apt install -y podman podman-docker uidmap curl git x11-apps | ||
</syntaxhighlight> | snap install code --classic</syntaxhighlight> | ||
; Package overview | ; Package overview | ||
* ''' | * '''Podman:''' Docker-compatible container engine | ||
* '''podman-docker:''' enables Docker-CLI compatibility | * '''podman-docker:''' enables Docker-CLI compatibility | ||
* '''uidmap:''' required for rootless containers | * '''uidmap:''' required for rootless containers | ||
* '''x11-apps:''' optional, useful to test X11 GUI forwarding | * '''x11-apps:''' optional, useful to test X11 GUI forwarding | ||
* '''code:''' Visual Studio Code - Our IDE | |||
== 2 | == 2. Enable the Podman User Socket == | ||
Enable the user socket so VS Code can communicate with Podman: | Enable the user socket so VS Code can communicate with Podman: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash">systemctl --user enable --now podman.socket</syntaxhighlight> | ||
systemctl --user enable --now podman.socket | |||
</syntaxhighlight> | |||
Add this line to your shell configuration (for example <code>~/.bashrc</code>): | Add this line to your shell configuration (for example <code>~/.bashrc</code>): | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash">echo 'export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock' >> ~/.bashrc</syntaxhighlight> | ||
export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock | |||
</syntaxhighlight> | |||
Reload the configuration: | Reload the configuration: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash">source ~/.bashrc</syntaxhighlight> | ||
source ~/.bashrc | |||
</syntaxhighlight> | Create folder for your Source | ||
<syntaxhighlight lang="bash">mkdir ~/source | |||
cd ~/source</syntaxhighlight> | |||
== | == 3. Configure Visual Studio Code == | ||
Start VS Code: | Start VS Code: | ||
| Line 56: | Line 43: | ||
Install these extensions: | Install these extensions: | ||
* '''C#''' | |||
* '''C# Dev Kit''' | |||
* '''Dev Containers''' — <code>ms-vscode-remote.remote-containers</code> | * '''Dev Containers''' — <code>ms-vscode-remote.remote-containers</code> | ||
* ''' | * '''Container Tools''' | ||
Optional: adjust your user settings (<code>settings.json</code>) so VS Code uses Podman directly: | Optional: adjust your user settings (<code>settings.json</code>) so VS Code uses Podman directly: | ||
<syntaxhighlight lang="json"> | <syntaxhighlight lang="json">{ | ||
{ | "dev.containers.dockerPath": "podman", | ||
"dev.containers.dockerSocketPath": "unix:///run/user/1000/podman/podman.sock", | |||
"containers.environment": { | |||
} | "DOCKER_HOST": "unix:///run/user/1000/podman/podman.sock", | ||
</syntaxhighlight> | "CONTAINERS_STORAGE_CONF": "/home/dev/.config/containers/storage.conf", | ||
"XDG_DATA_HOME": "/home/dev/.local/share", | |||
"XDG_RUNTIME_DIR": "/run/user/${localEnv:UID}" | |||
}, | |||
"containers.containerClient": "com.microsoft.visualstudio.containers.podman", | |||
"containers.orchestratorClient": "com.microsoft.visualstudio.orchestrators.podmancompose", | |||
"containers.commands.attach": "${containerCommand} exec -it ${containerId} ${shellCommand}", | |||
"dev.containers.defaultFeatures": { | |||
} | |||
}</syntaxhighlight>Install .NET SDK, there should be a message | |||
== | == 4. Build the MAUI Docker Environment Locally == | ||
Clone the repository and build the container image on your own system: | Clone the repository and build the container image on your own system: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash">cd ~/source | ||
git clone https://github.com/MauiGtk/maui-docker.git | git clone https://github.com/MauiGtk/maui-docker.git | ||
cd maui-docker | cd ~/source/maui-docker | ||
podman build -t maui-env . | podman build -t maui-env .</syntaxhighlight> | ||
</syntaxhighlight> | |||
This creates a local image named <code>maui-env</code> that will be used by VS Code when opening the project inside a Dev Container. | This creates a local image named <code>maui-env</code> that will be used by VS Code when opening the project inside a Dev Container. | ||
== | == 5. Allow GUI Access (X11) == | ||
To run graphical MAUI GTK applications, allow the container to use your X display: | To run graphical MAUI GTK applications, allow the container to use your X display: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash">xhost +local:</syntaxhighlight> | ||
xhost +local: | |||
</syntaxhighlight> | |||
(You can later restrict access again with <code>xhost -local:</code>.) | (You can later restrict access again with <code>xhost -local:</code>.) | ||
== 6. Clone the maui-linux Project == | |||
You can just clone the maui-linux repository | |||
<syntaxhighlight lang="bash">git clone https://github.com/MauiGtk/maui-linux.git</syntaxhighlight> | |||
or you could clone the lytico repository | |||
<syntaxhighlight lang="bash">git clone https://github.com/lytico/maui.git</syntaxhighlight> | |||
I don't know witch is a better point to start, in future maui-linux.net will provide it's own stable compilable repository | |||
== 7. Open the Project in VS Code == | == 7. Open the Project in VS Code == | ||
| Line 94: | Line 100: | ||
Open the project folder: | Open the project folder: | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash">cd ~/source/maui-docker | ||
cd maui-docker | code .</syntaxhighlight> | ||
code . | |||
</syntaxhighlight> | |||
Then run | Then run Ctrl + Shift + P → “Dev Containers: Reopen in Container”. | ||
VS Code will start a Podman container based on the included <code>.devcontainer</code> configuration. | VS Code will start a Podman container based on the included <code>.devcontainer</code> configuration. | ||
== 8. Run the MAUI Sample Application == | == 8. Build Solution == | ||
In VS Code, go to Terminal and run<syntaxhighlight lang="bash"> | |||
dotnet build Microsoft.Maui.BuildTasks.slnf | |||
</syntaxhighlight> | |||
== 9. Run the MAUI Sample Application == | |||
Inside the container terminal, execute: | Inside the container terminal, execute: | ||
| Line 123: | Line 132: | ||
; Container fails to start | ; Container fails to start | ||
: Check if the socket is active: | : Check if the socket is active: | ||
systemctl --user status podman.socket | |||
== 10. Downloads == | |||
For a faster installation, here is a shell script, after running go to Step 7 | |||
https://wiki.maui-linux.net/downloads/install_ubuntu_podman_mauilinux.sh | |||
And for easy start you can Download a full working Xubuntu 24.04 VM here | |||
https://wiki.maui-linux.net/downloads/Maui Linux V1.0 (Xubuntu).rar | |||
User: dev | |||
Password: Dev123 | |||
== | == 11. Summary == | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 143: | Line 169: | ||
|} | |} | ||
With these steps, a clean Ubuntu 24.04 VM can run | With these steps, a clean Ubuntu 24.04 VM can run Visual Studio Code Dev Containers using Podman, including full GUI support for .NET MAUI GTK applications. | ||
Latest revision as of 04:51, 11 November 2025
Visual Studio Code with Podman on a Fresh Ubuntu 24.04 VM
This guide explains exactly how to set up Visual Studio Code (VS Code) with Podman on a clean installation of Ubuntu 24.04 LTS inside a virtual machine, and how to build and run the maui-docker project locally inside a Dev Container.
1. Prepare the System
After installing Ubuntu 24.04, open a terminal and install the required packages:
sudo apt update
sudo apt install -y podman podman-docker uidmap curl git x11-apps
snap install code --classic
- Package overview
- Podman: Docker-compatible container engine
- podman-docker: enables Docker-CLI compatibility
- uidmap: required for rootless containers
- x11-apps: optional, useful to test X11 GUI forwarding
- code: Visual Studio Code - Our IDE
2. Enable the Podman User Socket
Enable the user socket so VS Code can communicate with Podman:
systemctl --user enable --now podman.socket
Add this line to your shell configuration (for example ~/.bashrc):
echo 'export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock' >> ~/.bashrc
Reload the configuration:
source ~/.bashrc
Create folder for your Source
mkdir ~/source
cd ~/source
3. Configure Visual Studio Code
Start VS Code:
code .
Install these extensions:
- C#
- C# Dev Kit
- Dev Containers —
ms-vscode-remote.remote-containers - Container Tools
Optional: adjust your user settings (settings.json) so VS Code uses Podman directly:
{
"dev.containers.dockerPath": "podman",
"dev.containers.dockerSocketPath": "unix:///run/user/1000/podman/podman.sock",
"containers.environment": {
"DOCKER_HOST": "unix:///run/user/1000/podman/podman.sock",
"CONTAINERS_STORAGE_CONF": "/home/dev/.config/containers/storage.conf",
"XDG_DATA_HOME": "/home/dev/.local/share",
"XDG_RUNTIME_DIR": "/run/user/${localEnv:UID}"
},
"containers.containerClient": "com.microsoft.visualstudio.containers.podman",
"containers.orchestratorClient": "com.microsoft.visualstudio.orchestrators.podmancompose",
"containers.commands.attach": "${containerCommand} exec -it ${containerId} ${shellCommand}",
"dev.containers.defaultFeatures": {
}
}
Install .NET SDK, there should be a message
4. Build the MAUI Docker Environment Locally
Clone the repository and build the container image on your own system:
cd ~/source
git clone https://github.com/MauiGtk/maui-docker.git
cd ~/source/maui-docker
podman build -t maui-env .
This creates a local image named maui-env that will be used by VS Code when opening the project inside a Dev Container.
5. Allow GUI Access (X11)
To run graphical MAUI GTK applications, allow the container to use your X display:
xhost +local:
(You can later restrict access again with xhost -local:.)
6. Clone the maui-linux Project
You can just clone the maui-linux repository
git clone https://github.com/MauiGtk/maui-linux.git
or you could clone the lytico repository
git clone https://github.com/lytico/maui.git
I don't know witch is a better point to start, in future maui-linux.net will provide it's own stable compilable repository
7. Open the Project in VS Code
Open the project folder:
cd ~/source/maui-docker
code .
Then run Ctrl + Shift + P → “Dev Containers: Reopen in Container”.
VS Code will start a Podman container based on the included .devcontainer configuration.
8. Build Solution
In VS Code, go to Terminal and run
dotnet build Microsoft.Maui.BuildTasks.slnf
9. Run the MAUI Sample Application
Inside the container terminal, execute:
cd /mauienv/maui/src/Controls/samples/Controls.Sample
dotnet run --framework net8.0-gtk
If everything is configured correctly, a GTK window should appear on your Ubuntu 24.04 desktop.
9. Troubleshooting
- VS Code reports “Docker not found”
- Ensure
podman-dockeris installed andDOCKER_HOSTis set correctly.
- GUI does not open / “cannot open display”
- Verify
$DISPLAY(e.g.:0) is set and that you have runxhost +local:.
- Container fails to start
- Check if the socket is active:
systemctl --user status podman.socket
10. Downloads
For a faster installation, here is a shell script, after running go to Step 7
https://wiki.maui-linux.net/downloads/install_ubuntu_podman_mauilinux.sh
And for easy start you can Download a full working Xubuntu 24.04 VM here
https://wiki.maui-linux.net/downloads/Maui+Linux+V1.0+(Xubuntu).rar
User: dev
Password: Dev123
11. Summary
| Component | Purpose |
|---|---|
| Ubuntu 24.04 VM | Clean test environment |
| Podman | Docker-compatible container engine |
| podman-docker | Docker CLI compatibility layer |
| podman.socket | API endpoint for VS Code |
| VS Code Dev Containers | Container-based development environment |
| X11 forwarding | Enables GUI applications inside containers |
With these steps, a clean Ubuntu 24.04 VM can run Visual Studio Code Dev Containers using Podman, including full GUI support for .NET MAUI GTK applications.