Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save BillBarnhill/683eb22dafe62d81118c72e86194c6fe to your computer and use it in GitHub Desktop.

Select an option

Save BillBarnhill/683eb22dafe62d81118c72e86194c6fe to your computer and use it in GitHub Desktop.
Setup Podman on Chrome OS Flex and Crostini

Actual versions for this guide:

  • Operating System: Debian GNU/Linux 12 (bookworm)
  • Kernel: Linux 6.1.64-09049-g010fe86d9eae
  • Architecture: x86-64
  • Podman: v1.7.1

Installation

1. Install Podman:

sudo apt install podman

2. Verify installation:

$ podman --version 
podman version 4.3.1

3. Install Podman Desktop:

sudo tar xvf podman-desktop-1.7.1.tar.gz --directory=/opt 

4. Create desktop shortcut for ChromeOS: [1]

  • Create the applications directory if it not exists yet:
mkdir ~/.local/share/applications 
  • Create Podman.desktop file using nvim (sudo apt install neovim):
nvim ~/.local/share/applications/Podman.desktop
  • Paste the following content (adjust icon path if needed):
[Desktop Entry]
Name=Podman Desktop
Exec=/opt/podman-desktop-1.7.1/podman-desktop %u
Terminal=false
Type=Application
Icon=/home/<put-your-username-here>/Images/podman.png 
  • Wait a few seconds or reboot Crostini/ChromeOS and icon should appear in the app launcher

5. Test Installation

  • Create a PostgreSQL container:
podman run -p 5432:5432 --name <your-container-name> -e POSTGRES_PASSWORD=postgres -d docker.io/postgres
  • Open Podman Desktop and you will see your container (restart the app if there are no info)

Troubleshooting

Error: cannot find UID/GID for user [2]:

  1. In Chrome, open crosh shell (Ctrl + Alt + T)
$ vsh termina
$ lxc exec penguin -- /bin/sh -c "printf '%s\n' '1000:100000:65536' | tee /etc/subuid /etc/subgid"

Error: potentially insufficient UIDs or GIDs [3]:

podman system migrate

Working with Rust

Get the latest

$ podman pull docker.io/rust:later

Create the Containerfile

Note: for our simple dev run we only want to test lib unit tests. Add --bin to add binaries unit tests. Or just use test to run lib unit tests, binaries unit tests, doc tests, and integration tests.

FROM rust:latest

# Install any additional dependencies your project might need
RUN apt-get update && apt-get install -y build-essential

WORKDIR /app

# Copy your project files
# Except we don't anymore, we use -v .:/app to mount it instead so we get changes
#COPY . .

# Build your Rust project (optional, can be done later)
# RUN cargo test
# Except we don't anymore, because RUN executes the command on image build
# Instead we use ENTRYPOINT, which executes the command on image start
ENTRYPOINT cargo test --bins

Create the build-it script, and chmod +x the file afterwards

!#/bin/bash
podman build -t my-advent-of-code:latest .

Create the run-it script, and chmod +x the file afterwards

Note: we don't want to create target in our source dir, so instead of mounting . in /app we mount Cargo.lock, Cargo.toml, and src.

!#/bin/bash
podman run -v ./Cargo.lock:/app/Cargo.lock -v ./Cargo.toml:/app/Cargo.toml -v ./src:/app/src my-advent-of-code:latest

Now start a project and build the image

Change the name in the scripts from advent-of-code to your choice.

$ cargo init advent-of-code
$ cd advent-of-code
$ cp ../Containerfile .
$ cp ../build-it .
$ cp ../run-it .
$ ./build-it
$ ./run-it

References

  1. https://support.google.com/pixelbook/thread/708306/how-do-i-add-linux-apps-to-the-home-screen?hl=en
  2. https://ntk.me/2021/05/14/podman-in-crostini/
  3. containers/podman#12715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment