Ayanokoji
Commands

Docker

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all parts it needs, such as libraries and other dependencies, and ship it all out as one package.

Documentation

Commands

Init

Initialize a Docker Compose file with database services.

npx ayanokoji docker init

Options

OptionDescription
-c, --cwd <cwd>Working directory (default: current directory)
--env-path <path>Custom path for .env file
--skip-conflictsSkip existing env vars without prompting

Features

  • Interactive service selection - Choose from multiple database services
  • Connection strings - Outputs ready-to-use connection strings after setup
  • Health checks - All services include health check configuration
  • Environment file support - Optionally write connection strings to .env
  • Conflict handling - Prompts to override or skip existing env vars
  • Gitignore integration - Auto-adds .env to .gitignore

Remove

Remove services from an existing Docker Compose file.

npx ayanokoji docker remove

Options

OptionDescription
-c, --cwd <cwd>Working directory (default: current directory)
--env-path <path>Custom path for .env file

Features

  • Interactive service selection - Choose which services to remove
  • Volume cleanup - Automatically removes orphaned volumes
  • Environment cleanup - Optionally removes related env vars from .env

Supported Services

Databases

ServiceImageDefault PortConnection String
PostgreSQLpostgres5432postgresql://user:pass@localhost:5432/db
MySQLmysql3306mysql://user:pass@localhost:3306/db
MariaDBmariadb3306mysql://user:pass@localhost:3306/db
MongoDBmongo27017mongodb://user:pass@localhost:27017

Caching

ServiceImageDefault PortConnection String
Redisredis6379redis://:pass@localhost:6379
Valkeyvalkey/valkey6379redis://:pass@localhost:6379

Message Queues

ServiceImagePortsConnection String
RabbitMQrabbitmq:management5672, 15672amqp://user:pass@localhost:5672

Storage

ServiceImagePortsConnection String
MinIOminio/minio9000, 9001http://localhost:9000

Development Tools

ServiceImagePortsConnection String
Mailpitaxllent/mailpit1025, 8025smtp://localhost:1025

Environment Variables

When you choose to write connection strings to .env, the following variables are created:

ServiceVariables
PostgreSQLPOSTGRESQL_URL
MySQLMYSQL_URL
MariaDBMARIADB_URL
MongoDBMONGODB_URL
RedisREDIS_URL
ValkeyVALKEY_URL
RabbitMQRABBITMQ_URL
MinIOMINIO_URL, MINIO_ACCESS_KEY, MINIO_SECRET_KEY
MailpitMAILPIT_URL, MAILPIT_UI_URL

Health Checks

All services include Docker health checks for better container orchestration:

healthcheck:
  test: ["CMD-SHELL", "..."]
  interval: 10s
  timeout: 5s
  retries: 5

This enables using depends_on with condition: service_healthy in your compose files.

Example Output

Running ayanokoji docker init and selecting PostgreSQL and Redis generates:

services:
  postgres:
    image: postgres:latest
    environment:
      POSTGRES_USER: docker
      POSTGRES_PASSWORD: docker
      POSTGRES_DB: docker
    ports:
      - "5432:5432"
    volumes:
      - postgres_data:/var/lib/postgresql/data
    healthcheck:
      test:
        - CMD-SHELL
        - pg_isready -U docker -d docker
      interval: 10s
      timeout: 5s
      retries: 5
  redis:
    image: redis:latest
    command:
      - redis-server
      - "--requirepass"
      - docker
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    healthcheck:
      test:
        - CMD-SHELL
        - redis-cli -a docker ping | grep PONG
      interval: 10s
      timeout: 5s
      retries: 5
volumes:
  postgres_data: {}
  redis_data: {}
Edit on GitHub

Last updated on

On this page