Full Control Over Applications in TrueNAS Scale via SSH

TrueNAS SSH

TrueNAS Scale, with its powerful web interface, makes installing and managing applications simple and intuitive. However, any advanced user will sooner or later discover that the real power and flexibility lie in the command line. It’s worth noting that since version 24.04 (Electric Eel), TrueNAS Scale has undergone a significant transformation, moving away from the previous k3s system (a lightweight Kubernetes distribution) in favour of native container management using Docker. This change has significantly simplified the architecture and made working directly with containers more accessible.

True freedom comes from a direct SSH connection, which bypasses the limitations of the in-browser terminal. It allows you to transform from a regular user into a knowledgeable administrator who can look ‘under the bonnet’ of any application, diagnose problems in real-time, and manage the system with a precision unavailable from the graphical user interface. This article is a comprehensive guide to managing applications in TrueNAS Scale using the terminal, based on the native Docker commands that have become the new foundation of the application system.

Step 1: Identifying Running Applications

Before we can start managing applications, we need to know what is actually running on our system. The graphical interface shows us the application names, but the terminal gives us insight into the actual containers.

Listing Containers: docker ps

The basic command is docker ps. It displays a list of all currently running containers.

docker ps

The output of this command is a table with key information:

  • CONTAINER ID: A unique identifier.
  • IMAGE: The name of the image from which the container was created.
  • STATUS: Information on how long the container has been running.
  • PORTS: Port mappings.
  • NAMES: The most important piece of information for us – the user-friendly name of the container, which we will use in subsequent commands (e.g., ix-jellyfin-jellyfin-1).

If you also want to see stopped containers, add the -a flag: docker ps -a.

Monitoring Resources in Real-Time: docker stats

An even better way to get a quick overview is docker stats. This command displays a dynamic, live-updating table showing CPU, RAM, and network resource usage for each container. It’s the perfect tool to identify at a glance which application is putting a load on the system.

docker stats

Step 2: Getting Inside a Container – docker exec

Once you’ve identified a container, you can get inside it to browse files, edit configurations, or perform advanced diagnostics.

docker exec -it ix-jellyfin-jellyfin-1 /bin/bash

Let’s break down this command:

  • docker exec: Execute a command in a running container.
  • -it: Key flags that signify an interactive session (-i) with a pseudo-terminal allocated (-t).
  • ix-jellyfin-jellyfin-1: The name of our container.
  • /bin/bash: The command we want to run inside – in this case, the Bash shell.

After running the command, the terminal prompt will change, indicating that you are now “inside”. You can move freely around the container’s file system using commands like ls, cd, etc. To exit and return to TrueNAS, simply type exit or use the shortcut Ctrl + D.

Why are Tools like top, ps, or nano Missing?

While working inside a container, you might encounter command not found errors. This is intentional. Many modern Docker images (including the official Jellyfin one) are so-called minimalist or “distroless” images. They do not contain any additional tools, only the application itself and its libraries. This is a best practice that increases security and reduces the image size.

In such cases, you must rely on the external tools provided by Docker itself.

Step 3: Diagnostics and Troubleshooting

When an application isn’t working correctly, the terminal is your best friend.

Viewing Logs: docker logs

This is the most important diagnostic command. It displays everything the application has written to its logs.

docker logs ix-nextcloud-nextcloud-1

If you want to follow the logs in real-time, add the -f (--follow) flag:

docker logs -f ix-nextcloud-nextcloud-1

Detailed Inspection: docker inspect

The docker inspect command returns a vast amount of detailed information about a container in JSON format – its IP address, attached volumes, environment variables, and much more.

docker inspect ix-tailscale-tailscale-1

Step 4: Managing Files and the Application Lifecycle

The terminal gives you full control over the files and the state of your applications.

Copying Files: docker cp

This is an extremely useful command for transferring files between the TrueNAS system and a container, without needing to go inside it.

Copying from a container to TrueNAS (e.g., for a configuration backup):

docker cp ix-nginx-proxy-manager-npm-1:/data/nginx /mnt/YourPool/backups/

Copying from TrueNAS to a container:

docker cp /mnt/YourPool/data/new-certificate.pem ix-nginx-proxy-manager-npm-1:/data/custom_ssl/

Controlling the Application State

Instead of clicking in the graphical interface, you can quickly manage your applications:

To stop an application:

docker stop ix-qbittorrent-qbittorrent-1

To start a stopped application:

docker start ix-qbittorrent-qbittorrent-1

To restart an application (the most common operation):

docker restart ix-qbittorrent-qbittorrent-1

From User to Administrator

Mastering a few basic Docker commands in the SSH terminal opens up a whole new dimension of managing TrueNAS Scale. You are no longer dependent on the limitations of the graphical interface and gain the tools to understand how your applications really work.

The ability to quickly check logs, monitor resources in real-time, edit any configuration file, or make a swift backup – all this makes working with the system more efficient and troubleshooting faster. Connecting via SSH is not just a convenience; it’s a fundamental tool for any conscientious administrator who wants full control over their server.

Komentarze

Leave a Reply

Your email address will not be published. Required fields are marked *