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
Documents the openTerminal() JavaScript function for opening container console and log viewers. Includes parameter reference, usage examples, and dashboard tile considerations. Also adds web terminal URL patterns to file-path-reference.
Unraid® provides a built-in `openTerminal()` JavaScript function for opening container console sessions and viewing container logs in a popup window. This function handles spawning the ttyd terminal server and opening the WebSocket connection.
185
+
186
+
### The openTerminal Function
187
+
188
+
The global `openTerminal(tag, name, more)` function is defined in Unraid's core JavaScript (HeadInlineJS.php) and is available on all pages.
189
+
190
+
| Parameter | Description | Values |
191
+
|-----------|-------------|--------|
192
+
| `tag` | Terminal type | `'docker'` for containers, `'ttyd'` or `'syslog'` for system |
193
+
| `name` | Container name | Must match Docker container name exactly |
194
+
| `more` | Shell or log flag | Shell command (e.g., `'bash'`, `'sh'`) or `'.log'` for logs |
195
+
196
+
### Opening Container Console
197
+
198
+
To open an interactive shell session in a container:
199
+
200
+
```javascript
201
+
// Open bash console in a container
202
+
openTerminal('docker', 'mycontainer', 'bash');
203
+
204
+
// Open sh console (for containers without bash)
205
+
openTerminal('docker', 'mycontainer', 'sh');
206
+
```
207
+
208
+
### Viewing Container Logs
209
+
210
+
To open a live-streaming log viewer for a container, pass `'.log'` as the third parameter:
211
+
212
+
```javascript
213
+
// Open container logs in a terminal window
214
+
openTerminal('docker', 'mycontainer', '.log');
215
+
```
216
+
217
+
{: .important }
218
+
> The `'.log'` value must include the leading dot. This tells Unraid to open a log viewer instead of a shell session.
219
+
220
+
### How It Works Internally
221
+
222
+
When `openTerminal()` is called, it:
223
+
224
+
1. **Sanitizes the name**: Replaces spaces and `#` characters with underscores
225
+
2. **Opens a popup window**: Creates a sized popup for the terminal
226
+
3. **Calls OpenTerminal.php**: Makes an AJAX request to `/webGui/include/OpenTerminal.php` which spawns the ttyd process
227
+
4. **Navigates to socket URL**: After a short delay, redirects the popup to the WebSocket URL:
228
+
- Logs: `/logterminal/{name}.log/`
229
+
- Console: The function constructs the appropriate webterminal URL
230
+
231
+
```javascript
232
+
// Simplified view of what openTerminal does internally
233
+
function openTerminal(tag, name, more) {
234
+
name = name.replace(/[ #]/g, "_");
235
+
var popup = window.open('', name + (more == '.log' ? more : ''), 'width=1200,height=800');
236
+
237
+
// Determine socket URL
238
+
var socket = '/logterminal/' + name + (more == '.log' ? more : '') + '/';
On dashboard tiles, the global `openTerminal` function may not be available if `docker.js` isn't loaded. Check for its existence before calling, or use a fallback:
285
+
286
+
```javascript
287
+
function openContainerTerminal(name, isLogs, shell) {
> The fallback method of directly opening the URL may not work reliably because it doesn't call `OpenTerminal.php` to spawn the ttyd process first. Always prefer using the global `openTerminal()` function when available.
304
+
182
305
## Working with Images
183
306
184
307
Common image operations including listing, pulling, and removing. When pulling images, redirect stderr to capture progress output. Always check return values for error handling.
Unraid provides terminal access via ttyd WebSocket URLs. These are used by the `openTerminal()` JavaScript function (see [Docker Integration - Container Terminal Access](../advanced/docker-integration.md#container-terminal-access)).
> Don't navigate to these URLs directly. Use the `openTerminal()` JavaScript function which calls `/webGui/include/OpenTerminal.php` to spawn the ttyd process first.
0 commit comments