Skip to content

Commit 7bc3129

Browse files
committed
Update current feature
1 parent 9b844a7 commit 7bc3129

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

_desk/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ RUN apt-get -y update && \
1212
apt-get -y clean
1313

1414
RUN apt-get -y update && \
15-
apt-get -y install curl bash-completion git gnupg jq \
15+
apt-get -y install auditd curl bash-completion git gnupg jq \
1616
kubectx lsb-release locales make \
1717
nano openssh-client parallel \
1818
unzip vim wget zsh \

resources/desk.sh

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,26 @@ MOUNTS="$MOUNTS --volume /tmp:/tmp"
3636
MOUNTS="$MOUNTS --volume /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro"
3737
MOUNTS="$MOUNTS --volume /usr/local/share/ca-certificates:/usr/local/share/ca-certificates"
3838

39-
# Openshift binary is huge and optional, so it is not build inside the image
40-
oc_bin=$(which oc) || oc_bin=""
41-
if [ -n "$oc_bin" ]; then
42-
MOUNTS="$MOUNTS --volume $oc_bin:/usr/local/bin/oc"
39+
# Optional binaries that are not built inside the image
40+
for binary in oc kind cosign trivy docker; do
41+
bin_path=$(which $binary) || bin_path=""
42+
if [ -n "$bin_path" ]; then
43+
MOUNTS="$MOUNTS --volume $bin_path:/usr/local/bin/$binary"
44+
fi
45+
done
46+
47+
# Mount Docker socket for Docker daemon access
48+
DOCKER_GROUP_ADD=""
49+
if [ -S "/var/run/docker.sock" ]; then
50+
MOUNTS="$MOUNTS --volume /var/run/docker.sock:/var/run/docker.sock"
51+
# Get docker group ID and add user to docker group in container
52+
docker_gid=$(stat -c '%g' /var/run/docker.sock)
53+
DOCKER_GROUP_ADD="--group-add $docker_gid"
4354
fi
4455

4556
if [ "$SHOWDOCKERCMD" = true ]; then
4657
echo "docker run -it --net=host \
47-
$MOUNTS --rm \
58+
$MOUNTS $DOCKER_GROUP_ADD --rm \
4859
--user=$(id -u):$(id -g $USER) \
4960
-w $HOME -- \
5061
\"$IMAGE\""
@@ -54,7 +65,7 @@ else
5465
echo " Welcome in k8s toolbox desk"
5566
echo "oOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoOoO"
5667
docker run -it --net=host \
57-
$MOUNTS --rm \
68+
$MOUNTS $DOCKER_GROUP_ADD --rm \
5869
--user=$(id -u):$(id -g $USER) \
5970
-w $HOME -- \
6071
"$IMAGE" $CMD

0 commit comments

Comments
 (0)