Commands Reference
This chapter provides comprehensive documentation for all Dockim commands, their options, and usage examples.
Command Overview
Dockim provides a cohesive set of commands organized by functionality:
- Project Management:
init,init-config - Container Lifecycle:
build,up,stop,down - Development Tools:
neovim,shell,exec - Network Management:
port
Global Options
These options are available for all commands:
--help, -h Show help information
--version, -V Show version information
--verbose, -v Enable verbose output
--quiet, -q Suppress non-error output
--config <PATH> Use custom config file
Project Management Commands
dockim init
Initialize a new Dockim project with dev container configuration.
Usage:
dockim init [OPTIONS]
Options:
--force, -f Overwrite existing files
--template <NAME> Use specific project template
--name <NAME> Set container name
Examples:
# Initialize with default settings
dockim init
# Initialize with custom name
dockim init --name "my-web-app"
# Force overwrite existing configuration
dockim init --force
# Use a specific template
dockim init --template nodejs
Generated Files:
.devcontainer/devcontainer.json- Main container configuration.devcontainer/compose.yml- Docker Compose setup.devcontainer/Dockerfile- Custom image definition
Templates:
default- Basic Ubuntu containernodejs- Node.js development environmentpython- Python development environmentrust- Rust development environmentgo- Go development environment
dockim init-config
Create a global configuration file with default settings.
Usage:
dockim init-config [OPTIONS]
Options:
--force, -f Overwrite existing config
--editor Open config in default editor after creation
Examples:
# Create default config
dockim init-config
# Overwrite existing config
dockim init-config --force
# Create and open in editor
dockim init-config --editor
Configuration Location:
- Linux/macOS:
~/.config/dockim/config.toml - Windows:
%APPDATA%\dockim\config.toml
Container Lifecycle Commands
dockim build
Build the development container image.
Usage:
dockim build [OPTIONS]
Options:
--rebuild Force complete rebuild (ignore cache)
--no-cache Build without using Docker cache
--neovim-from-source Build Neovim from source instead of binaries
--progress <TYPE> Progress output type: auto, plain, tty
Examples:
# Standard build
dockim build
# Force rebuild from scratch
dockim build --rebuild
# Build without Docker cache
dockim build --no-cache
# Build with Neovim from source
dockim build --neovim-from-source
# Build with plain progress output
dockim build --progress plain
Build Process:
- Read
.devcontainer/Dockerfile - Process build arguments and context
- Execute Docker build with appropriate options
- Tag image for container usage
dockim up
Start the development container.
Usage:
dockim up [OPTIONS]
Options:
--rebuild Rebuild image before starting
--detach, -d Run container in background
--remove-orphans Remove containers for services not in compose file
Examples:
# Start container (build if needed)
dockim up
# Rebuild and start
dockim up --rebuild
# Start in background
dockim up --detach
# Clean up orphaned containers
dockim up --remove-orphans
Startup Process:
- Check if image exists (build if needed)
- Start Docker Compose services
- Wait for container readiness
- Set up port forwarding
dockim stop
Stop the running development container.
Usage:
dockim stop [OPTIONS]
Options:
--timeout <SECONDS> Wait timeout before force stopping (default: 10)
--all Stop all Dockim containers
Examples:
# Stop current project container
dockim stop
# Stop with custom timeout
dockim stop --timeout 30
# Stop all Dockim containers
dockim stop --all
Stop Process:
- Send SIGTERM to container processes
- Wait for graceful shutdown
- Force stop if timeout exceeded
- Clean up port forwards
dockim down
Stop and remove the development container.
Usage:
dockim down [OPTIONS]
Options:
--volumes, -v Remove associated volumes
--images Remove associated images
--timeout <SECONDS> Wait timeout before force removal
Examples:
# Remove container (keep volumes and images)
dockim down
# Remove container and volumes
dockim down --volumes
# Remove container, volumes, and images
dockim down --volumes --images
# Remove with custom timeout
dockim down --timeout 30
Removal Process:
- Stop container if running
- Remove container
- Remove volumes (if specified)
- Remove images (if specified)
- Clean up port forwards
Development Tools Commands
dockim neovim
Launch Neovim with remote UI support.
Usage:
dockim neovim [OPTIONS] [FILES...]
dockim v [OPTIONS] [FILES...] # Short alias
Options:
--no-remote-ui Run Neovim directly in container (no remote UI)
--host-port <PORT> Specify host port for remote connection
--server-port <PORT> Specify container port for Neovim server
--wait Wait for editor to close before returning
Examples:
# Launch with remote UI
dockim neovim
dockim v
# Open specific files
dockim neovim src/main.rs README.md
# Launch without remote UI
dockim neovim --no-remote-ui
# Use custom host port
dockim neovim --host-port 8080
# Wait for editor to close
dockim neovim --wait config.toml
Remote UI Process:
- Start container if not running
- Launch Neovim server in container
- Set up port forwarding
- Start local Neovim client
- Establish remote connection
dockim shell
Open an interactive shell in the container.
Usage:
dockim shell [OPTIONS]
dockim sh [OPTIONS] # Short alias
Options:
--shell <SHELL> Use specific shell (overrides config)
--user <USER> Run as specific user
--workdir <PATH> Set working directory
Examples:
# Open default shell
dockim shell
dockim sh
# Use specific shell
dockim shell --shell /bin/bash
# Run as root user
dockim shell --user root
# Start in specific directory
dockim shell --workdir /workspace/src
Shell Selection Priority:
--shellcommand option- Global config
shellsetting - Container default shell
/bin/shas fallback
dockim bash
Open a Bash shell in the container.
Usage:
dockim bash [OPTIONS]
Options:
--user <USER> Run as specific user
--workdir <PATH> Set working directory
Examples:
# Open bash shell
dockim bash
# Run as root
dockim bash --user root
# Start in specific directory
dockim bash --workdir /tmp
dockim exec
Execute a command in the running container.
Usage:
dockim exec [OPTIONS] COMMAND [ARGS...]
Options:
--interactive, -i Keep STDIN open
--tty, -t Allocate pseudo-TTY
--user <USER> Run as specific user
--workdir <PATH> Set working directory
--env <KEY=VALUE> Set environment variables
Examples:
# Execute simple command
dockim exec ls -la
# Interactive command with TTY
dockim exec -it python
# Run as specific user
dockim exec --user root apt update
# Set working directory
dockim exec --workdir /workspace npm test
# Set environment variables
dockim exec --env DEBUG=1 npm start
# Complex command with arguments
dockim exec git commit -m "Add new feature"
Network Management Commands
dockim port
Manage port forwarding between host and container.
Usage:
dockim port <SUBCOMMAND> [OPTIONS]
dockim port add
Add port forwarding rules.
Usage:
dockim port add [OPTIONS] <PORT_SPEC>...
Port Specifications:
3000 Host port 3000 → Container port 3000
8080:3000 Host port 8080 → Container port 3000
:3000 Auto-assign host port → Container port 3000
localhost:3000:3000 Bind to localhost only
Options:
--protocol <PROTO> Port protocol: tcp (default), udp
--bind <IP> Bind to specific IP address
Examples:
# Forward same ports
dockim port add 3000 8080 5432
# Forward different ports
dockim port add 8080:3000 8081:3001
# Auto-assign host ports
dockim port add :3000 :8080
# Bind to localhost only
dockim port add localhost:3000:3000
# UDP port forwarding
dockim port add 1234 --protocol udp
# Bind to specific IP
dockim port add 3000:3000 --bind 192.168.1.100
dockim port ls
List active port forwarding rules.
Usage:
dockim port ls [OPTIONS]
Options:
--format <FORMAT> Output format: table (default), json, yaml
--filter <FILTER> Filter ports by criteria
Examples:
# List all active ports
dockim port ls
# JSON output
dockim port ls --format json
# Filter by port number
dockim port ls --filter port=3000
# Filter by protocol
dockim port ls --filter protocol=tcp
Output Format:
HOST PORT CONTAINER PORT PROTOCOL STATUS
3000 3000 tcp active
8080 3000 tcp active
5432 5432 tcp active
dockim port rm
Remove port forwarding rules.
Usage:
dockim port rm [OPTIONS] <PORT>...
Options:
--all, -a Remove all port forwards
--protocol <PROTO> Remove only specified protocol ports
Examples:
# Remove specific ports
dockim port rm 3000 8080
# Remove all port forwards
dockim port rm --all
# Remove only TCP ports
dockim port rm --all --protocol tcp
Command Exit Codes
Dockim commands use standard exit codes:
0- Success1- General error2- Misuse of command (invalid arguments)125- Docker daemon error126- Container command not executable127- Container command not found130- Process terminated by user (Ctrl+C)
Environment Variables
Commands respect these environment variables:
DOCKIM_CONFIG_DIR # Override config directory
DOCKIM_LOG_LEVEL # Set log level (debug, info, warn, error)
DOCKIM_NO_COLOR # Disable colored output
DOCKER_HOST # Docker daemon connection
COMPOSE_PROJECT_NAME # Docker Compose project name
Configuration Files
Commands may read configuration from:
- Command-line options (highest priority)
- Environment variables
- Project config (
.devcontainer/devcontainer.json) - Global config (
~/.config/dockim/config.toml) - Built-in defaults (lowest priority)
Examples by Workflow
Starting a New Project
# Initialize project
dockim init --template nodejs
# Build and start
dockim build
dockim up
# Open editor
dockim neovim
# Set up port forwarding
dockim port add 3000 8080
Daily Development
# Start development environment
dockim up
# Run tests
dockim exec npm test
# Open editor if not running
dockim neovim src/app.js
# Check running services
dockim port ls
# Execute build
dockim exec npm run build
Container Maintenance
# Update container image
dockim build --rebuild
# Clean restart
dockim down
dockim up
# Clean up everything
dockim down --volumes --images
Debugging and Inspection
# Check container status
dockim exec ps aux
# View logs
dockim exec journalctl --follow
# Network diagnostics
dockim exec netstat -tuln
dockim port ls
# Interactive debugging
dockim shell --user root
Shell Completion
Dockim supports shell completion for bash, zsh, and fish:
# Bash
dockim completion bash > /etc/bash_completion.d/dockim
# Zsh
dockim completion zsh > "${fpath[1]}/_dockim"
# Fish
dockim completion fish > ~/.config/fish/completions/dockim.fish
Next: Explore Advanced Usage for complex scenarios, custom setups, and integration patterns.