@@ -36,15 +36,26 @@ MOUNTS="$MOUNTS --volume /tmp:/tmp"
3636MOUNTS=" $MOUNTS --volume /etc/group:/etc/group:ro -v /etc/passwd:/etc/passwd:ro"
3737MOUNTS=" $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 "
4354fi
4455
4556if [ " $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 \" "
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