You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I wanna have access to distrobox features, so I used distrobox for creation.
Basically it is container for development, it contains libraries and SDKs which I need. I use it because I dont wanna fill up my host system with tons of libraries + SDKs, + Im switching to immutable distro in future.
So I trust everything in that container, so I dont care about lower security when using --pid=host, etc, I would say I need it, because dev container should have as much access as possible.
So as you can see I created container mostly with default settings except nvidia support and pid stuff.
But I need sometimes some volumes when working, and every project needs different volumes, so I want to mount to container volumes during runtime somehow.
So I created this script:
#!/bin/bash
# Dynamicky bind mountne host path do bežiaceho podman kontajnera a vytvorí symlink vnútri
set -e
if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "Usage: $0 <container-name> <host-path> [container-path]"
exit 1
fi
CONTAINER_NAME=$1
HOST_PATH=$2
if [ $# -eq 3 ]; then
CONTAINER_PATH=$3
else
CONTAINER_PATH=$HOST_PATH
fi
if [ ! -e "$HOST_PATH" ]; then
echo "❌ Error: host path '$HOST_PATH' does not exist."
exit 2
fi
CID=$(podman ps -q -f name="^${CONTAINER_NAME}$")
if [ -z "$CID" ]; then
echo "❌ Error: container '$CONTAINER_NAME' is not running."
exit 3
fi
MOUNT_BASE="/tmp/distrobox_mounts/$CID"
MOUNT_PATH="$MOUNT_BASE$CONTAINER_PATH"
echo "📁 Creating mount target on host: $MOUNT_PATH"
podman unshare mkdir -p "$(dirname "$MOUNT_PATH")"
if [ -e "$MOUNT_PATH" ]; then
echo "ℹ️ Mount path already exists."
else
if [ -f "$HOST_PATH" ] || [ -S "$HOST_PATH" ]; then
echo "📄 Creating empty file/socket as mount point: $MOUNT_PATH"
podman unshare touch "$MOUNT_PATH"
elif [ -d "$HOST_PATH" ]; then
echo "📁 Creating directory as mount point: $MOUNT_PATH"
podman unshare mkdir -p "$MOUNT_PATH"
else
echo "❌ Error: '$HOST_PATH' is neither file, socket, nor directory."
exit 4
fi
fi
echo "🔗 Bind mounting $HOST_PATH → $MOUNT_PATH"
podman unshare mount --bind "$HOST_PATH" "$MOUNT_PATH"
echo "🔗 Creating symlink inside container from $CONTAINER_PATH → $MOUNT_PATH"
podman exec --user root "$CONTAINER_NAME" mkdir -p "$(dirname "$CONTAINER_PATH")" || true
podman exec --user root "$CONTAINER_NAME" rm -rf "$CONTAINER_PATH" || true
podman exec --user root "$CONTAINER_NAME" ln -s "$MOUNT_PATH" "$CONTAINER_PATH"
echo "✅ Bind mount and symlink successful."
I can call it like pbind /run/dbus//run/dbus/system_bus_socket and it will create mount at /tmp/distrobox_mounts/$CID and then it will symlink to "original" location, it creates mount and symlink, but it is not working (my app in dev container cannot communicate with system_bus_socket).
This is output from host:
ls -l /run/dbus/system_bus_socket
srw-rw-rw- - root 5 Aug 12:02 /run/dbus/system_bus_socket
and this is from container:
ls -l /run/dbus/system_bus_socket
lrwxrwxrwx - root 5 Aug 22:10 /run/dbus/system_bus_socket -> /tmp/distrobox_mounts/13074e3e9251/run/dbus/system_bus_socket
I mean permissions should be alright, because in both cases user has UID 1000 and PID should be shared. This is only thing which I really really need/want.
Please I would be happy for any solution.
Thank you
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, so long story short, I created my container like:
distrobox create --yes --name devbox --image docker-registry.server.home/devbox --nvidia --additional-flags "--pid=host"
I wanna have access to distrobox features, so I used distrobox for creation.
Basically it is container for development, it contains libraries and SDKs which I need. I use it because I dont wanna fill up my host system with tons of libraries + SDKs, + Im switching to immutable distro in future.
So I trust everything in that container, so I dont care about lower security when using
--pid=host
, etc, I would say I need it, because dev container should have as much access as possible.So as you can see I created container mostly with default settings except nvidia support and pid stuff.
But I need sometimes some volumes when working, and every project needs different volumes, so I want to mount to container volumes during runtime somehow.
So I created this script:
I can call it like
pbind /run/dbus//run/dbus/system_bus_socket
and it will create mount at/tmp/distrobox_mounts/$CID
and then it will symlink to "original" location, it creates mount and symlink, but it is not working (my app in dev container cannot communicate with system_bus_socket).This is output from host:
and this is from container:
I mean permissions should be alright, because in both cases user has UID 1000 and PID should be shared.
This is only thing which I really really need/want.
Please I would be happy for any solution.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions