Configuration

Customize StackMark behavior and manage your stacks configuration.

Configuration File

StackMark stores its configuration in ~/.stackmark/config.json. This file is created automatically when you first use StackMark.

Location

Platform Path
Linux ~/.stackmark/config.json
macOS ~/.stackmark/config.json
Windows %USERPROFILE%\.stackmark\config.json

Structure

~/.stackmark/config.json
{
  "portStart": 9000,
  "stacks": {
    "myapp": {
      "path": "/home/user/Dev/myapp",
      "domain": "myapp.local",
      "ports": {
        "nginx": 9003,
        "mysql": 9004,
        "redis": 9005
      }
    },
    "api-project": {
      "path": "/home/user/Dev/api",
      "ports": {
        "node": 9010,
        "postgres": 9011
      }
    }
  }
}

Configuration Options

portStart

The starting port number for automatic port allocation. Default: 9000

StackMark allocates ports sequentially starting from this number. Each service in each stack gets a unique port.

stacks

Object containing all registered stacks. Each stack has:

Property Description
path Absolute path to the docker-compose.yml directory
domain Optional local domain for /etc/hosts
ports Map of service names to allocated external ports

Port Allocation

StackMark automatically allocates ports to avoid conflicts between stacks.

How It Works

  1. When you stackmark add a project, StackMark scans docker-compose.yml
  2. For each service with exposed ports, it allocates the next available port starting from portStart
  3. Port mappings are stored in the config file
  4. When starting a stack, a temporary override file remaps the ports

Example

docker-compose.yml (original)
services:
  nginx:
    ports:
      - "80:80"
  mysql:
    ports:
      - "3306:3306"
StackMark port mapping
nginx: localhost:9003 → container:80
mysql: localhost:9004 → container:3306

Your original docker-compose.yml is never modified. StackMark creates temporary override files at runtime.

Environment Variables

Configure StackMark behavior using environment variables:

Variable Description Default
STACKMARK_CONFIG_DIR Override config directory location ~/.stackmark
STACKMARK_PORT_START Override starting port number 9000
DOCKER_COMPOSE_CMD Docker Compose command to use docker compose
Example
$ export STACKMARK_PORT_START=8000
$ stackmark add myapp
Stack "myapp" registered (ports start at 8000)

Manual Configuration

You can edit the config file directly to:

  • Change port assignments
  • Add or modify domains
  • Update stack paths
Note: After manually editing the config, restart any running stacks for changes to take effect.
terminal
$ nano ~/.stackmark/config.json
# Make your changes...
$ stackmark restart myapp

Reset Configuration

To reset StackMark to default settings:

terminal
$ rm -rf ~/.stackmark
# Config will be recreated on next use

Warning: This will remove all registered stacks. You'll need to re-add them with stackmark add.