Skip to content

Commit 17ba2cb

Browse files
authored
Merge pull request #2778 from jeffng-or/docker-shell-container-engine
added container engine detection to docker_shell
2 parents a70d32c + 707cbec commit 17ba2cb

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

flow/util/docker_shell

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11
#!/usr/bin/env bash
22

33
set -ex
4+
5+
#
6+
# Method to use docker CLI to determine if we're using docker or podman
7+
#
8+
# Sets container_engine global variable with either "docker" or "podman"
9+
#
10+
get_container_engine () {
11+
local DOCKER_VERSION_STRING=$(docker --version 2> /dev/null)
12+
13+
if [[ "$DOCKER_VERSION_STRING" == *"Docker"* ]]; then
14+
container_engine="docker"
15+
elif [[ "$DOCKER_VERSION_STRING" == *"podman"* ]]; then
16+
container_engine="podman"
17+
else
18+
echo "Unable to determine container engine using docker CLI"
19+
exit 1
20+
fi
21+
}
22+
423
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
524

25+
get_container_engine
26+
627
WORKSPACE=$(pwd)
728
YOSYS_EXE=${YOSYS_EXE:-/OpenROAD-flow-scripts/tools/install/yosys/bin/yosys}
829
OPENROAD_EXE=${OPENROAD_EXE:-/OpenROAD-flow-scripts/tools/install/OpenROAD/bin/openroad}
@@ -17,9 +38,15 @@ if test -t 0; then
1738
DOCKER_INTERACTIVE=-ti
1839
fi
1940

41+
if [[ $container_engine == "podman" ]]; then
42+
user_args="--privileged --userns=keep-id"
43+
else
44+
user_args="-u $(id -u ${USER}):$(id -g ${USER})"
45+
fi
46+
2047
# Most of these options below has to do with allowing to
2148
# run the OpenROAD GUI from within Docker.
22-
docker run --privileged -u $(id -u ${USER}):$(id -g ${USER}) \
49+
docker run $user_args \
2350
-e LIBGL_ALWAYS_SOFTWARE=1 \
2451
-e "QT_X11_NO_MITSHM=1" \
2552
-e XDG_RUNTIME_DIR=/tmp/xdg-run \

0 commit comments

Comments
 (0)