Skip to content

Commit

Permalink
create: properly handle platform specification for alien architectures.
Browse files Browse the repository at this point in the history
Fix #1644

Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed Jan 19, 2025
1 parent 9b53b53 commit 589ad7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
12 changes: 11 additions & 1 deletion distrobox-create
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ container_image_default="registry.fedoraproject.org/fedora-toolbox:latest"
container_init_hook=""
container_manager="autodetect"
container_manager_additional_flags=""
container_platform=""
container_name=""
container_name_default="my-distrobox"
container_hostname=""
Expand Down Expand Up @@ -214,6 +215,7 @@ Options:
this will make host's processes not visible from within the container. (assumes --unshare-process)
may require additional packages depending on the container image: https://github.com/89luca89/distrobox/blob/main/docs/useful_tips.md#using-init-system-inside-a-distrobox
--nvidia: try to integrate host's nVidia drivers in the guest
--platform: specify which platform to use, eg: linux/arm64
--unshare-devsys: do not share host devices and sysfs dirs from host
--unshare-groups: do not forward user's additional groups into the container
--unshare-ipc: do not share ipc namespace with host
Expand Down Expand Up @@ -399,6 +401,13 @@ while :; do
shift
fi
;;
--platform)
if [ -n "$2" ]; then
container_platform="--platform=${2}"
shift
shift
fi
;;
-a | --additional-flags)
if [ -n "$2" ]; then
container_manager_additional_flags="${container_manager_additional_flags} ${2}"
Expand Down Expand Up @@ -654,6 +663,7 @@ generate_create_command()
{
# Set the container hostname the same as the container name.
result_command="${container_manager} create"
result_command="${result_command} ${container_platform}"
# use the host's namespace for ipc, network, pid, ulimit
result_command="${result_command}
--hostname \"${container_hostname}\"
Expand Down Expand Up @@ -1015,7 +1025,7 @@ if [ "${container_always_pull}" -eq 1 ] ||
case "${response}" in
y | Y | Yes | yes | YES)
# Pull the image
${container_manager} pull "${container_image}"
${container_manager} pull ${container_platform} "${container_image}"
;;
n | N | No | no | NO)
printf >&2 "next time, run this command first:\n"
Expand Down
1 change: 1 addition & 0 deletions docs/usage/distrobox-create.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ graphical apps (X11/Wayland), and audio.
this will make host's processes not visible from within the container. (assumes --unshare-process)
may require additional packages depending on the container image: https://github.com/89luca89/distrobox/blob/main/docs/useful_tips.md#using-init-system-inside-a-distrobox
--nvidia: try to integrate host's nVidia drivers in the guest
--platform: specify which platform to use, eg: linux/arm64
--unshare-devsys: do not share host devices and sysfs dirs from host
--unshare-groups: do not forward user's additional groups into the container
--unshare-ipc: do not share ipc namespace with host
Expand Down

0 comments on commit 589ad7e

Please sign in to comment.