-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from kaweezle/feature/podman
✨ Make a podman image
- Loading branch information
Showing
8 changed files
with
107 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
function RunDockerInWsl { | ||
# Take $Env:DOCKER_WSL or 'docker' if undefined | ||
$DockerWSL = if ($null -eq $Env:DOCKER_WSL) { "docker" } else { $Env:DOCKER_WSL } | ||
# Try to find an existing distribution with the name | ||
$existing = Get-ChildItem HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue('DistributionName') -eq $DockerWSL } | ||
if ($null -eq $existing) { | ||
# Fail if the distribution doesn't exist | ||
throw "The WSL distribution [$DockerWSL] does not exist !" | ||
} else { | ||
# Ensure docker is started | ||
wsl -d $DockerWSL -u root openrc default | ||
# Perform the requested command | ||
wsl -d $DockerWSL /usr/bin/docker $args | ||
} | ||
} | ||
|
||
Set-Alias -Name docker -Value RunDockerInWsl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# this doesn't work as WSL will kill the process 15 seconds after it has started | ||
# If this is run from the command line, this won't happen. | ||
# [boot] | ||
# command = openrc default | ||
|
||
[user] | ||
default = alpine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ARG BASE_VERSION=latest | ||
|
||
FROM ghcr.io/kaweezle/alpine-boxes-base:${BASE_VERSION} | ||
|
||
USER root | ||
|
||
RUN apk add --no-cache podman && \ | ||
echo alpine:100000:65536 >>/etc/subuid && \ | ||
echo alpine:100000:65536 >>/etc/subgid | ||
|
||
COPY ./oci2wsl.sh /usr/local/bin/oci2wsl | ||
COPY ./dockeralias.ps1 /dockeralias.ps1 | ||
COPY ./wsl.conf /etc/wsl.conf | ||
|
||
USER alpine |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
function RunPodmanInWsl { | ||
# Take $Env:PODMAN_WSL or 'docker' if undefined | ||
$PodmanWSL = if ($null -eq $Env:PODMAN_WSL) { "podman" } else { $Env:PODMAN_WSL } | ||
# Try to find an existing distribution with the name | ||
$existing = Get-ChildItem HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss | Where-Object { $_.GetValue('DistributionName') -eq $PodmanWSL } | ||
if ($null -eq $existing) { | ||
# Fail if the distribution doesn't exist | ||
throw "The WSL distribution [$PodmanWSL] does not exist !" | ||
} else { | ||
# Perform the requested command | ||
wsl -d $PodmanWSL -u alpine /usr/bin/podman $args | ||
} | ||
} | ||
|
||
Set-Alias -Name docker -Value RunPodmanInWsl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env zsh | ||
|
||
usage() { | ||
echo "oci2wsl: Create a WSL distribution from an OCI image" | ||
echo | ||
echo "Usage: oci2wsl <image> <name> <directoy>" | ||
echo | ||
exit 1 | ||
} | ||
|
||
if [ $# -ne 3 ]; then | ||
usage | ||
fi | ||
|
||
image="$1" | ||
name="$2" | ||
directory="$3" | ||
|
||
if [ ! -d "$directory" ]; then | ||
echo "Error! $directory is not a directory." | ||
usage | ||
fi | ||
|
||
ID=$(podman create -q $image 2>/dev/null) | ||
if [ -z "$ID" ]; then | ||
echo "Error! creation of container from $image impossible." | ||
exit 1 | ||
fi | ||
|
||
podman export $ID | wsl.exe --import $name $directory - | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "Error! Creation of the image impossible!" | ||
podman rm $ID >/dev/null | ||
exit 1 | ||
fi | ||
|
||
podman rm $ID >/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[user] | ||
default = alpine |