@@ -42,22 +42,35 @@ function get_docker_info_once() {
42
42
if [[ -z " ${DOCKER_INFO} " ]]; then
43
43
declare -g DOCKER_INFO
44
44
declare -g DOCKER_IN_PATH=" no"
45
-
46
- # if "docker" is in the PATH...
45
+ declare -g DOCKER_COMMAND=" docker"
46
+ declare -g DOCKER_NETWORK=" "
47
+ declare -g DOCKER_MOUNT_OPTS=" "
48
+
49
+ # Detect container engine - prefer Docker for compatibility, but support Podman
47
50
if [[ -n " $( command -v docker) " ]]; then
48
51
display_alert " Docker is in the path" " Docker in PATH" " debug"
52
+ DOCKER_COMMAND=" docker"
53
+ display_alert " Docker detected" " Using Docker" " debug"
49
54
DOCKER_IN_PATH=" yes"
55
+ elif [[ -n " $( command -v podman) " ]]; then
56
+ DOCKER_COMMAND=" sudo podman"
57
+ DOCKER_NETWORK=" --network host"
58
+ DOCKER_MOUNT_OPTS=" ,suid,dev" # Required mount options for Podman
59
+ display_alert " Podman detected" " Using Podman with sudo (required for Armbian builds)" " info"
50
60
fi
51
61
52
62
# Shenanigans to go around error control & capture output in the same effort.
53
- DOCKER_INFO=" $( { docker info 2> /dev/null && echo " DOCKER_INFO_OK" ; } || true) "
63
+ DOCKER_INFO=" $( { $DOCKER_COMMAND info 2> /dev/null && echo " DOCKER_INFO_OK" ; } || true) "
54
64
declare -g -r DOCKER_INFO=" ${DOCKER_INFO} " # readonly
55
65
56
66
declare -g DOCKER_INFO_OK=" no"
57
67
if [[ " ${DOCKER_INFO} " =~ " DOCKER_INFO_OK" ]]; then
58
68
DOCKER_INFO_OK=" yes"
59
69
fi
60
70
declare -g -r DOCKER_INFO_OK=" ${DOCKER_INFO_OK} " # readonly
71
+ declare -g -r DOCKER_COMMAND=" ${DOCKER_COMMAND} "
72
+ declare -g -r DOCKER_NETWORK=" ${DOCKER_NETWORK} "
73
+ declare -g -r DOCKER_MOUNT_OPTS=" ${DOCKER_MOUNT_OPTS} "
61
74
fi
62
75
return 0
63
76
}
@@ -73,8 +86,8 @@ function is_docker_ready_to_go() {
73
86
display_alert " Can't use Docker" " Actually ALREADY UNDER DOCKER!" " debug"
74
87
return 1
75
88
fi
76
- if [[ -z " $( command -v docker) " ]]; then
77
- display_alert " Can't use Docker" " docker command not found" " debug"
89
+ if [[ -z " $( command -v docker) " ]] && [[ -z " $( command -v podman ) " ]] ; then
90
+ display_alert " Can't use Docker" " docker or podman command not found" " debug"
78
91
return 1
79
92
fi
80
93
@@ -97,19 +110,19 @@ function cli_handle_docker() {
97
110
# Purge Armbian Docker images
98
111
if [[ " ${1} " == dockerpurge && -f /etc/debian_version ]]; then
99
112
display_alert " Purging Armbian Docker containers" " " " wrn"
100
- docker container ls -a | grep armbian | awk ' {print $1}' | xargs docker container rm & > /dev/null
101
- docker image ls | grep armbian | awk ' {print $3}' | xargs docker image rm & > /dev/null
113
+ $DOCKER_COMMAND container ls -a | grep armbian | awk ' {print $1}' | xargs $DOCKER_COMMAND container rm & > /dev/null
114
+ $DOCKER_COMMAND image ls | grep armbian | awk ' {print $3}' | xargs $DOCKER_COMMAND image rm & > /dev/null
102
115
# removes "dockerpurge" from $1, thus $2 becomes $1
103
116
shift
104
- set -- " docker " " $@ "
117
+ set -- $DOCKER_COMMAND " $@ "
105
118
fi
106
119
107
120
# Docker shell
108
121
if [[ " ${1} " == docker-shell ]]; then
109
122
# this swaps the value of $1 with 'docker', and life continues
110
123
shift
111
124
SHELL_ONLY=yes
112
- set -- " docker " " $@ "
125
+ set -- $DOCKER_COMMAND " $@ "
113
126
fi
114
127
115
128
}
@@ -323,7 +336,7 @@ function docker_cli_build_dockerfile() {
323
336
324
337
if [[ " ${do_force_pull} " == " no" ]]; then
325
338
# Check if the base image is up to date.
326
- local_image_sha=" $( docker images --no-trunc --quiet " ${DOCKER_ARMBIAN_BASE_IMAGE} " ) "
339
+ local_image_sha=" $( $DOCKER_COMMAND images --no-trunc --quiet " ${DOCKER_ARMBIAN_BASE_IMAGE} " ) "
327
340
display_alert " Checking if base image exists at all" " local_image_sha: '${local_image_sha} '" " debug"
328
341
if [[ -n " ${local_image_sha} " ]]; then
329
342
display_alert " Armbian docker image" " already exists: ${DOCKER_ARMBIAN_BASE_IMAGE} " " info"
@@ -336,10 +349,10 @@ function docker_cli_build_dockerfile() {
336
349
if [[ " ${do_force_pull:- yes} " == " yes" ]]; then
337
350
display_alert " Pulling" " ${DOCKER_ARMBIAN_BASE_IMAGE} " " info"
338
351
local pull_failed=" yes"
339
- run_host_command_logged docker pull " ${DOCKER_ARMBIAN_BASE_IMAGE} " && pull_failed=" no"
352
+ run_host_command_logged $DOCKER_COMMAND pull " ${DOCKER_ARMBIAN_BASE_IMAGE} " && pull_failed=" no"
340
353
341
354
if [[ " ${pull_failed} " == " no" ]]; then
342
- local_image_sha=" $( docker images --no-trunc --quiet " ${DOCKER_ARMBIAN_BASE_IMAGE} " ) "
355
+ local_image_sha=" $( $DOCKER_COMMAND images --no-trunc --quiet " ${DOCKER_ARMBIAN_BASE_IMAGE} " ) "
343
356
display_alert " New local image sha after pull" " local_image_sha: ${local_image_sha} " " debug"
344
357
# print current date and time in epoch format; touches mtime of file
345
358
echo " ${DOCKER_ARMBIAN_BASE_IMAGE} |${local_image_sha} |$( date +%s) " >> " ${docker_marker_dir} " /last-pull
@@ -360,7 +373,7 @@ function docker_cli_build_dockerfile() {
360
373
display_alert " Building" " Dockerfile via '${DOCKER_BUILDX_OR_BUILD[*]} '" " info"
361
374
362
375
BUILDKIT_COLORS=" run=123,20,245:error=yellow:cancel=blue:warning=white" \
363
- run_host_command_logged docker " ${DOCKER_BUILDX_OR_BUILD[@]} " -t " ${DOCKER_ARMBIAN_INITIAL_IMAGE_TAG} " -f " ${SRC} " /Dockerfile " ${SRC} "
376
+ run_host_command_logged $DOCKER_COMMAND " ${DOCKER_BUILDX_OR_BUILD[@]} " -t " ${DOCKER_ARMBIAN_INITIAL_IMAGE_TAG} " -f " ${SRC} " /Dockerfile " ${SRC} "
364
377
}
365
378
366
379
function docker_cli_prepare_launch() {
@@ -503,16 +516,16 @@ function docker_cli_prepare_launch() {
503
516
# type=volume, without source=, is an anonymous volume -- will be auto cleaned up together with the container;
504
517
# this could also be a type=tmpfs if you had enough ram - but armbian already does tmpfs for you if you
505
518
# have enough RAM (inside the container) so don't bother.
506
- DOCKER_ARGS+=(" --mount" " type=volume,destination=${DOCKER_ARMBIAN_TARGET_PATH} /${MOUNT_DIR} " )
519
+ DOCKER_ARGS+=(" --mount" " type=volume,destination=${DOCKER_ARMBIAN_TARGET_PATH} /${MOUNT_DIR}${DOCKER_MOUNT_OPTS} " )
507
520
;;
508
521
bind)
509
522
display_alert " Mounting" " bind mount for '${MOUNT_DIR} '" " debug"
510
523
mkdir -p " ${SRC} /${MOUNT_DIR} "
511
- DOCKER_ARGS+=(" --mount" " type=bind,source=${SRC} /${MOUNT_DIR} ,target=${DOCKER_ARMBIAN_TARGET_PATH} /${MOUNT_DIR} " )
524
+ DOCKER_ARGS+=(" --mount" " type=bind,source=${SRC} /${MOUNT_DIR} ,target=${DOCKER_ARMBIAN_TARGET_PATH} /${MOUNT_DIR}${DOCKER_MOUNT_OPTS} " )
512
525
;;
513
526
namedvolume)
514
527
display_alert " Mounting" " named volume id '${volume_id} ' for '${MOUNT_DIR} '" " debug"
515
- DOCKER_ARGS+=(" --mount" " type=volume,source=armbian-${volume_id} ,destination=${DOCKER_ARMBIAN_TARGET_PATH} /${MOUNT_DIR} " )
528
+ DOCKER_ARGS+=(" --mount" " type=volume,source=armbian-${volume_id} ,destination=${DOCKER_ARMBIAN_TARGET_PATH} /${MOUNT_DIR}${DOCKER_MOUNT_OPTS} " )
516
529
;;
517
530
* )
518
531
display_alert " Unknown Mountpoint Type" " unknown volume type '${docker_kind} ' for '${MOUNT_DIR} '" " err"
@@ -585,13 +598,13 @@ function docker_cli_launch() {
585
598
# The amount of privileges and capabilities given is a bare minimum needed for losetup to work
586
599
if [[ ! -e /dev/loop0 ]]; then
587
600
display_alert " Running losetup in a temporary container" " because no loop devices exist" " info"
588
- run_host_command_logged docker run --rm --privileged --cap-add=MKNOD " ${DOCKER_ARMBIAN_INITIAL_IMAGE_TAG} " /usr/sbin/losetup -f
601
+ run_host_command_logged $DOCKER_COMMAND run $DOCKER_NETWORK --rm --privileged --cap-add=MKNOD " ${DOCKER_ARMBIAN_INITIAL_IMAGE_TAG} " /usr/sbin/losetup -f
589
602
fi
590
603
591
604
display_alert " -----------------Relaunching in Docker after ${SECONDS} s------------------" " here comes the 🐳" " info"
592
605
593
606
local -i docker_build_result
594
- if docker run " ${DOCKER_ARGS[@]} " " ${DOCKER_ARMBIAN_INITIAL_IMAGE_TAG} " /bin/bash " ${DOCKER_ARMBIAN_TARGET_PATH} /compile.sh" " ${ARMBIAN_CLI_FINAL_RELAUNCH_ARGS[@]} " ; then
607
+ if $DOCKER_COMMAND run $DOCKER_NETWORK " ${DOCKER_ARGS[@]} " " ${DOCKER_ARMBIAN_INITIAL_IMAGE_TAG} " /bin/bash " ${DOCKER_ARMBIAN_TARGET_PATH} /compile.sh" " ${ARMBIAN_CLI_FINAL_RELAUNCH_ARGS[@]} " ; then
595
608
docker_build_result=$? # capture exit code of test done in the line above.
596
609
display_alert " -------------Docker run finished after ${SECONDS} s------------------------" " 🐳 successful" " info"
597
610
else
@@ -623,8 +636,8 @@ function docker_purge_deprecated_volumes() {
623
636
for mountpoint in " ${ARMBIAN_MOUNTPOINTS_DEPRECATED[@]} " ; do
624
637
local volume_id=" armbian-${mountpoint// \/ / -} "
625
638
display_alert " Purging deprecated Docker volume" " ${volume_id} " " info"
626
- if docker volume inspect " ${volume_id} " & > /dev/null; then
627
- run_host_command_logged docker volume rm " ${volume_id} "
639
+ if $DOCKER_COMMAND volume inspect " ${volume_id} " & > /dev/null; then
640
+ run_host_command_logged $DOCKER_COMMAND volume rm " ${volume_id} "
628
641
display_alert " Purged deprecated Docker volume" " ${volume_id} OK" " info"
629
642
else
630
643
display_alert " Deprecated Docker volume not found" " ${volume_id} OK" " info"
0 commit comments