Container Attach
The /detail/:cluster/container/:containerName/attach endpoint of the Dashium API allows you to attach a Docker container using WebSockets.
Use this route to establish a WebSocket connection with a Docker container, enabling real-time interaction with the container's terminal.
Endpointβ
- Path:
/detail/:cluster/container/:containerName/attach - Method:
WebSocket - Parameters:
:cluster(Docker cluster identifier):containerName(Docker container name)
WebSocket Connectionβ
Connect to this route using the WebSocket protocol to establish bidirectional communication.
const ws = new WebSocket('wss://your-dashium-api.com/detail/cluster/1/container/your_container/attach');
Featuresβ
- Attach the Docker container in detached mode (stream).
- Transmit container stream data to the client via WebSocket.
- Manage client commands and send them to the Docker container.
Usage Exampleβ
Use the following code to establish a WebSocket connection with a Docker container and interact in real-time with the terminal.
const ws = new WebSocket('wss://your-dashium-api.com/detail/cluster/1/container/your_container/attach');
// Listen for container stream data
ws.onmessage = (event) => {
console.log(event.data); // Display terminal data
};
// Send commands to the container
ws.send('ls -l');
Upon success, you will be able to receive and send data in real-time with the specified Docker container terminal.