Skip to main content
Hands-on guide: setting up Portainer with Docker Compose using `mkdir` commands on Ubuntu 24.04 [defencedev.com](https://defe

Editorial illustration for Guide: Set Up Portainer with Docker Compose Using Simple mkdir Commands

Portainer Docker Management: Quick Setup Guide 2026

Guide: Set Up Portainer with Docker Compose Using Simple mkdir Commands

3 min read

Portainer gives you a web‑based console to manage Docker containers, which is handy when you’re building a self‑hosted AI stack from scratch. For beginners, the biggest hurdle is often the initial setup—getting the right files in the right place without tripping over permissions or syntax errors. That's why a clear, step‑by‑step guide matters.

While the concept sounds simple, the actual commands need to be entered precisely; a missed flag can leave Docker staring at a broken service. Here’s the thing: the guide walks you through creating the necessary folder structure and a compose file that tells Docker exactly which image to pull, how to keep it running, and where to expose the UI. Once that file is in place, the rest of the deployment proceeds automatically.

The following snippet shows the exact commands you’ll type to lay the groundwork before you paste the configuration that powers Portainer’s web interface. If you follow these steps precisely, you’ll have a functional Portainer instance ready to host the containers that will run your AI models, all without needing a separate orchestration service.

Create a directory for it and a docker-compose.yml file with the following command. mkdir -p ~/portainer && cd ~/portainer nano docker-compose.yml Paste the following configuration into the file. This tells Docker to download the Portainer image, restart it automatically, and expose its web interface on port 9000.

services: portainer: image: portainer/portainer-ce:latest container_name: portainer restart: unless-stopped ports: - "9000:9000" volumes: - /var/run/docker.sock:/var/run/docker.sock - portainer_data:/data volumes: portainer_data: Save the file (Ctrl+X, then Y, then Enter). Now, deploy Portainer: docker compose up -d Your output should look like this: Now navigate to http://YOUR_SERVER_IP:9000 in your browser. For me, it is http://localhost:9000 You may need to restart the server.

You can do that with the following command: sudo docker start portainer Create an admin account: And you will see the Portainer dashboard after creating an account. This is your mission control for all other containers. You can start, stop, view logs, and manage every other service from here.

It provides a simple API that n8n and other apps can use. // Deploying Ollama with Docker While Ollama can be installed directly, using Docker ensures consistency. Create a new directory and a docker-compose.yml file for it with the following command.

mkdir -p ~/ollama && cd ~/ollama nano docker-compose.yml Use this configuration. The volumes line is important because it stores your downloaded machine learning models persistently, so you don't lose them if the container restarts. services: ollama: image: ollama/ollama:latest container_name: ollama restart: unless-stopped ports: - "11434:11434" volumes: - ollama_data:/root/.ollama volumes: ollama_data: Deploy it: docker compose up -d // Pulling and Running Your First Model Once the container is running, you can pull a model.

Let's start with a capable but efficient model like Llama 3.2.

The guide walks you through the bare‑bones steps needed to get Portainer up and running on a home machine, starting with a simple `mkdir -p ~/portainer && cd ~/portainer` and a minimal `docker‑compose.yml`. By pulling the Portainer image, enabling automatic restarts and exposing the web UI, the tutorial promises a functional management console for the broader self‑hosted AI stack that also includes Docker, Ollama and n8n. If you’re looking for a quick way to avoid cloud fees while keeping data local, the instructions are clear and easy to follow.

However, the article stops short of discussing security hardening, backup strategies or scaling considerations, leaving those important aspects to the reader’s own research. Whether this straightforward setup will hold up under heavier workloads or more complex workflows remains uncertain. In short, the piece offers a concise entry point for beginners eager to assemble a private AI hub, but it does not cover the full operational lifecycle that many deployments eventually require.

Further Reading

Common Questions Answered

What is the purpose of creating a directory for Portainer using mkdir -p ~/portainer?

Creating a dedicated directory for Portainer helps organize your Docker container configuration files and keeps your project structure clean and manageable. This approach allows you to store the docker-compose.yml file and any related configuration in a specific location, making it easier to manage and track your Portainer installation.

How does the docker-compose.yml file configure the Portainer container?

The docker-compose.yml file specifies key configuration details for the Portainer container, including using the latest Portainer Community Edition image and setting up automatic restart behavior. It maps the Docker socket volume to allow Portainer to interact with the Docker daemon and exposes port 9000 to make the web interface accessible from the host machine.

Why is port 9000 important in the Portainer Docker Compose configuration?

Port 9000 is the default web interface port for Portainer, allowing users to access the container management dashboard through a web browser. By mapping port 9000:9000 in the docker-compose.yml file, you enable external access to the Portainer web interface, making it possible to manage Docker containers remotely through a user-friendly graphical interface.