In another blog post, we explored how Kubernetes clusters can be controlled from a browser. However, in this post, we will explore how we can achieve the same thing for Docker hosts.
While MCP servers may be all the rage, we continue to simplify things with our Systems AI agent, which now interacts with and manages Docker containers and resources without any MCP server. The Systems agent uses natural language to interact with Docker's API and supports managing containers without exposing APIs to the internet. This is what we will explore in this post. The agent does not store any Docker API credentials in MechCloud and instead relies on a proxy that you should run in your own network.
The Systems AI agent is a game changer for Developers and DevOps engineers:
No need to install desktop applications or CLI tools (e.g., Docker Desktop) to explore and manage Docker containers.
Use natural language instructions to query or manage Docker containers and images.
Customize UI components to display data for an instruction based on your requirements. We will cover this in a separate post.
Create rich dashboards to visualize your Docker resources as you prefer (e.g., displaying all containers and images in a single view). We will cover this in a separate post.
This AI agent is available free of cost for local/remote development environments.
In this post, we will explore how you can use the Systems AI agent to interact with a local/remote Docker host running in a private network.
π οΈ Install Docker
Install Docker by following the instructions on the Docker website. Ensure your Docker host is set up to expose its API over an HTTP port as well as a Unix socket.
- Edit the Docker daemon configuration (usually found in
/etc/docker/daemon.json
) -
{
"hosts": ["tcp://0.0.0.0:2375", "unix:///var/run/docker.sock"]
}
- Restart Docker to apply these settings -
sudo systemctl restart docker
π Run MechCloud proxy
Before MechCloud can connect to your private Docker Engine API, ensure the API is served on an HTTPS port and that CORS is set up correctly. We have created a Flask-based proxy to manage these requirements for the Docker Engine or any other API that doesn't meet these conditions. This proxy is available for convenience, but you can expose the Docker Engine API (and other APIs) using any reverse proxy you prefer, as long as it is on an HTTPS port and CORS is configured correctly.
Clone the proxy Git repository and follow the instructions in the README file to run it. Make sure the proxy.yaml
file of this proxy includes the following entry before starting it.:
'/docker/':
url: http://<docker_host_ip>:2375/
This setup will make the Docker Engine API accessible at the base URL https://127.0.0.1:6443/docker
. If the path in the proxy.yaml
file is different, replace docker
with the correct path (e.g., docker-1
). We will use this base URL when creating a system account for the Docker Engine API in MechCloud.
π Create a System account for Docker engine API
Open the URL
https://127.0.0.1:6443
in the same browser where you are planning to open the MechCloud application. You will see a certificate warning because we are using a self-signed certificate. Make sure to accept the self-signed certificate; otherwise, the MechCloud UI will not be able to communicate with the proxy.Log in to the MechCloud console.
Go to Infrastructure β System Accounts.
Choose a team from the dropdown menu.
Click the
New System Account
button.-
Enter or select the following details:
-
Account - Enter a name for the account (e.g.,
Docker 1
). -
System - Choose
Docker
from the dropdown menu. -
System Base URL - Enter
https://127.0.0.1:6443/docker
in this field. Note that it should not have a trailing slash. -
API Version - Click on
fetch version
link to get the Docker Engine API version. - Private API - Make sure the flag is turned on. This means the API is only available on a private network and should be accessed from the MechCloud UI, not from the backend.
-
Account - Enter a name for the account (e.g.,
- Click on
Save
button to add the system account for your docker host.
π€ Query resources in the your Docker host
Navigate to AI Agents β Systems Agent in the MechCloud console.
Select the team where you created a system account for your Docker Engine API.
Choose
Docker
from theSystem
dropdown.Select the account you created earlier in the
System Account
dropdown.-
Enter a prompt and click the blue button on the right. Sample prompts include:
- show system info
We have added FULL support for all the commands / operations in the following Docker Engine API versions -
1.49
1.48
1.47
1.46
1.45
We will add support for newer versions whenever a new version will be available. If you need support for older versions, then feel free to join our Discord server and post your requirement.
Note that UI components are NOT created for all the Docker Engine commands / operations. To find out which commands/operations are having associated UI components defined, simply go to MechCloud console β AI Agents β Operation Component Mappings, select any team and then select Docker
in the system dropdown. For commands/operations, which don't have corresponding UI components defined, you will see raw response from the Docker Engine API instead of a UI component displaying the same data in a table or some other format.
π Creating a dashboard for Docker resources
Follow the instructions in https://dev.to/mechcloud/how-to-build-comprehensive-dashboards-for-your-saas-and-cloud-apps-5bol post but instead of adding four cards, just add one card using mc system info
component and configure it to display one or more resource types from a Docker host. E.g. you can create a dashboard using following prompt which will display networks, volumes, images and containers using a single prompt -
list networks
list volumes
list images
list containers
Top comments (0)