import { useQuery } from "@tanstack/react-query"; import { AlertCircle, Unplug } from "lucide-react"; import * as YML from "yaml"; import { Alert, AlertDescription, AlertTitle } from "~/components/ui/alert"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "~/components/ui/card"; import { CodeBlock } from "~/components/ui/code-block"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "~/components/ui/table"; import type { Volume } from "~/lib/types"; import { getContainersUsingVolumeOptions, getSystemInfoOptions } from "../../../api-client/@tanstack/react-query.gen"; type Props = { volume: Volume; }; export const DockerTabContent = ({ volume }: Props) => { const yamlString = YML.stringify({ services: { nginx: { image: "nginx:latest", volumes: [`im-${volume.name}:/path/in/container`], }, }, volumes: { [`im-${volume.name}`]: { external: true, }, }, }); const dockerRunCommand = `docker run -v im-${volume.name}:/path/in/container nginx:latest`; const { data: systemInfo } = useQuery({ ...getSystemInfoOptions(), staleTime: 60000, // Cache for 1 minute }); const { data: containersData, isLoading, error, } = useQuery({ ...getContainersUsingVolumeOptions({ path: { name: volume.name } }), refetchInterval: 10000, refetchOnWindowFocus: true, }); const containers = containersData || []; const dockerAvailable = systemInfo?.data?.capabilities?.docker ?? true; const getStateClass = (state: string) => { switch (state) { case "running": return "bg-green-100 text-green-800"; case "exited": return "bg-orange-100 text-orange-800"; default: return "bg-gray-100 text-gray-800"; } }; return (
{!dockerAvailable && (
Docker Integration Unavailable Docker integration features are currently disabled. To enable them, you need to mount the following paths in your docker-compose.yml:
  • /var/run/docker.sock:/var/run/docker.sock
  • /run/docker/plugins:/run/docker/plugins

After adding these mounts, restart the Ironmount container.

)} Plug-and-play Docker integration This volume can be used in your Docker Compose files by referencing it as an external volume. The example demonstrates how to mount the volume to a service (nginx in this case). Make sure to adjust the path inside the container to fit your application's needs
Alternatively, you can use the following command to run a Docker container with the volume mounted
Containers Using This Volume {dockerAvailable ? "List of Docker containers mounting this volume." : "Docker integration is unavailable - enable it to see container information."} {!dockerAvailable && (

Docker integration is not available.

)} {dockerAvailable && isLoading &&
Loading containers...
} {dockerAvailable && error && (
Failed to load containers: {String(error)}
)} {dockerAvailable && !isLoading && !error && containers.length === 0 && (

No Docker containers are currently using this volume.

)} {dockerAvailable && !isLoading && !error && containers.length > 0 && (
Name ID State Image {containers.map((container) => ( {container.name} {container.id.slice(0, 12)} {container.state} {container.image} ))}
)}
); };