Container Console
The /detail/:cluster/container/:containerName/console endpoint of the Dashium API allows you to access the console of a specific Docker container.
Use this route to establish a WebSocket connection and interact with the container's terminal.
Endpointβ
- Path:
/detail/:cluster/container/:containerName/console - Method:
WebSocket - Parameters:
:cluster(Docker cluster identifier):containerName(Docker container name)
WebSocket Communicationβ
Establish a WebSocket connection with this endpoint for interactive communication with the specified container's terminal.
- Send messages to input commands into the container's terminal.
- Receive messages containing the output of the container's terminal.
Connection Managementβ
- The WebSocket connection automatically attaches to the container's terminal.
- Closing the WebSocket connection ends the terminal session.
Exampleβ
const socket = new WebSocket('ws://your-api-url/detail/your-cluster/container/your-container/console');
// Connection opened
socket.addEventListener('open', (event) => {
socket.send('ls -la'); // Send a command to the container
});
// Listen for messages
socket.addEventListener('message', (event) => {
console.log('Server message:', event.data);
});
// Connection closed
socket.addEventListener('close', (event) => {
console.log('WebSocket closed:', event);
});