Develop on Ubuntu 24.04 with Podman: Difference between revisions

From Wiki Maui Linux NET
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:
sudo apt update
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
snap install code --classic
</syntaxhighlight>
</syntaxhighlight>
; Package overview
; Package overview
* '''podman:''' Docker-compatible container engine   
* '''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. Install Visual Studio Code ==
== 2. Enable the Podman User Socket ==
 
<syntaxhighlight lang="bash">
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/microsoft.gpg > /dev/null
echo "deb [arch=amd64] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list
sudo apt update
sudo apt install -y code
</syntaxhighlight>
 
== 3. 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:
Line 35: Line 28:


<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock
echo 'export DOCKER_HOST=unix:///run/user/$UID/podman/podman.sock' >> ~/.bashrc
</syntaxhighlight>
</syntaxhighlight>


Line 44: Line 37:
</syntaxhighlight>
</syntaxhighlight>


== 4. Configure Visual Studio Code ==
== 3. Configure Visual Studio Code ==


Start VS Code:
Start VS Code:
Line 54: Line 47:
Install these extensions:
Install these extensions:
* '''Dev Containers''' — <code>ms-vscode-remote.remote-containers</code>
* '''Dev Containers''' — <code>ms-vscode-remote.remote-containers</code>
* '''Docker''' or '''Podman (Red Hat)'''
* '''Podman'''


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:
Line 65: Line 58:
</syntaxhighlight>
</syntaxhighlight>


== 5. Build the MAUI Docker Environment Locally ==
== 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:
Line 77: Line 70:
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.


== 6. Allow GUI Access (X11) ==
== 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:
Line 87: Line 80:
(You can later restrict access again with <code>xhost -local:</code>.)
(You can later restrict access again with <code>xhost -local:</code>.)


== 7. Open the Project in VS Code ==
== 6. Open the Project in VS Code ==


Open the project folder:
Open the project folder:
Line 99: Line 92:
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 ==
== 7. Run the MAUI Sample Application ==


Inside the container terminal, execute:
Inside the container terminal, execute:
Line 110: Line 103:
If everything is configured correctly, a GTK window should appear on your Ubuntu 24.04 desktop.
If everything is configured correctly, a GTK window should appear on your Ubuntu 24.04 desktop.


== 9. Troubleshooting ==
== 8. Troubleshooting ==


; VS Code reports “Docker not found”
; VS Code reports “Docker not found”
Line 122: Line 115:
   systemctl --user status podman.socket
   systemctl --user status podman.socket


== 10. Summary ==
== 9. Summary ==


{| class="wikitable"
{| class="wikitable"

Revision as of 23:34, 6 October 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

3. Configure Visual Studio Code

Start VS Code:

code .

Install these extensions:

  • Dev Containersms-vscode-remote.remote-containers
  • Podman

Optional: adjust your user settings (settings.json) so VS Code uses Podman directly:

{
  "dev.containers.dockerPath": "/usr/bin/podman",
  "dev.containers.composeCommand": "podman-compose"
}

4. Build the MAUI Docker Environment Locally

Clone the repository and build the container image on your own system:

git clone https://github.com/MauiGtk/maui-docker.git
cd 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. Open the Project in VS Code

Open the project folder:

cd 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.

7. 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.

8. Troubleshooting

VS Code reports “Docker not found”
Ensure podman-docker is installed and DOCKER_HOST is set correctly.
GUI does not open / “cannot open display”
Verify $DISPLAY (e.g. :0) is set and that you have run xhost +local:.
Container fails to start
Check if the socket is active:
 systemctl --user status podman.socket

9. 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.