docker
Manage Docker containers, images, networks and volumes.
Synopsis
xec docker [options] <subcommand>
xec d <subcommand> # aliasDescription
The docker command wraps common Docker operations: container lifecycle, image builds, networks, volumes, Compose, Swarm, and a set of pre-configured development services (Redis, PostgreSQL, Kafka, and others) that start with one line.
Docker must be installed and the daemon running.
Global Options
-o, --output <format>- Output format:text(default),json,yaml,csv-c, --config <path>- Path to configuration file--dry-run- Preview operations without executing them
Subcommands
Containers
xec docker container <cmd> # alias: crun [options] <image>- Run a new container-n, --name <name>,-p, --ports <ports...>,-v, --volumes <volumes...>,-e, --env <env...>--network <network>,--workdir <dir>,--user <user>,--entrypoint <cmd>-d, --detached,--rm,-i, --interactive,-t, --tty--restart <policy>,--label <labels...>,--privileged
exec [options] <container> <command...>- Execute a command in a running container-i, --interactive,-t, --tty,--user <user>,--workdir <dir>
stop [options] <containers...>- Stop containers (-t, --time <seconds>, default 10)remove [options] <containers...>- Remove containers (-f, --force); aliasrmlogs [options] <container>- View logs (-f, --follow,--tail <lines>,--since <time>,--timestamps)
Images
xec docker image <cmd> # alias: ibuild [options] <context>- Build from a Dockerfile-t, --tag <tag>,-f, --file <dockerfile>,--no-cache,--pull--platform <platform>,--build-arg <args...>,--target <stage>,--quiet
pull <image>- Pull an image from a registryremove [options] <images...>- Remove images (-f, --force); aliasrmilist- List images; aliasls
Pre-configured Services
xec docker service <cmd> # alias: sOne-line development services. Each takes -p, --port, -n, --name,
--version <tag>, --persistent and --data-path <path>; service-specific
flags below.
--persistent alone is enough: without --data-path the data goes to a
named Docker volume derived from the container name, which outlives the
container. Removing a service retains user-supplied data paths and volumes.
A Redis cluster removes only the network created by that instance; an
existing shared network is retained. Failed stop or remove operations are
reported as failures, including nodes left by an incomplete startup.
The Redis cluster startup checks every node and the expected membership before returning. Restarting saved nodes preserves their cluster configuration rather than issuing another cluster creation command.
The SSH preset uses the Core SSH/SFTP transport for commands and file transfer.
Its programmatic connection options use the same host-key policy as ordinary
SSH targets, including knownHostsPath and hostKeyChecking; the preset does
not disable verification or invoke a separate password helper.
redis- Redis (--password,--config-path)postgres- PostgreSQL (--password,--user,--database)mysql- MySQL (--password,--database)mongodb- MongoDB (--root-user,--root-password,--database,--replica-set)redis-cluster- Redis cluster (-m, --masters,-r, --replicas,-p, --base-port,--password,--network)kafka- Kafka with Zookeeper (--zookeeper <connection>,--broker-id <id>,--network)rabbitmq- RabbitMQ (-m, --management-port,--user,--password,--vhost)elasticsearch- Elasticsearch (--single-node). One container can only run as a single node, so--no-single-nodeis refused rather than silently ignored; for a real cluster, describe the nodes in a compose file or as separate targets.ssh- SSH server container for testing (--user,--password,--pubkey <path>,--authorized-keys <path>)list- List available services; aliasls
Compose
xec docker compose <cmd> # alias: dcup [options]- Create and start services (-f, --file,-p, --project,-d, --detached,--build,--profile <profiles...>)down [options]- Stop and remove services (-f, --file,-p, --project,-v, --volumes,--rmi)
Networks
xec docker network <cmd> # alias: ncreate [options] <name>- Create a network (-d, --driver,--subnet,--gateway,--ip-range,--attachable,--internal,--label <labels...>)remove <name>- Remove a network; aliasrm
Volumes
xec docker volume <cmd> # alias: vcreate [options] <name>- Create a volume (-d, --driver,--label <labels...>,--opt <options...>)remove [options] <name>- Remove a volume (-f, --force); aliasrm
Swarm
swarm init [options]- Initialize a swarm (--advertise-addr,--listen-addr,--data-path-addr)swarm leave [options]- Leave the swarm (-f, --force)
Shortcuts
ps [options]- List containers (-a, --all)images- List imagesprune [options]- Remove unused data (-a, --allimages too,-v, --volumes)quick-start- Interactive service starter
Examples
Containers and Images
# Run a container with ports and a mounted volume
xec docker container run nginx:alpine -n web -p 8080:80 -v ./html:/usr/share/nginx/html -d
# Execute a command inside it
xec docker container exec web "nginx -t"
# Follow its logs
xec docker container logs web -f
# Build and tag an image
xec docker image build . -t my-app:latest
# Clean up
xec docker container stop web
xec docker container rm webDevelopment Services
# Redis on the default port
xec docker service redis
# PostgreSQL with a persistent data directory
xec docker service postgres --password secret --persistent --data-path ./pgdata
# A three-master Redis cluster
xec docker service redis-cluster --masters 3 --replicas 1
# See what is available
xec docker service listCompose
xec docker compose up --build
xec docker compose down -vHousekeeping
xec docker ps -a
xec docker prune --all --volumesRelated Commands
in - Execute commands in containers declared as targets
logs - Stream logs from any target
copy - Copy files to and from containers
See Also
Docker Targets - Declaring containers in
.xec/config.yamlDocker Execution - The Docker adapter and fluent API