Skip to main content

Create

Create a new container on the target node from the specified image:

$ osapi client container docker create --image nginx:latest

Job ID: 550e8400-e29b-41d4-a716-446655440000

Hostname: server1
Container ID: a1b2c3d4e5f6
Name: eager_turing
Image: nginx:latest
State: running

Create a named container with environment variables, port mappings, and volume mounts:

$ osapi client container docker create \
--image nginx:latest \
--name my-nginx \
--env "PORT=8080" --env "DEBUG=true" \
--port "8080:80" --port "8443:443" \
--volume "/data:/var/lib/data"

Create a container without starting it immediately:

$ osapi client container docker create \
--image alpine:latest \
--name my-alpine \
--auto-start=false

Target a specific host:

$ osapi client container docker create \
--image redis:7 \
--name cache \
--target web-01

JSON Output

Use --json to get the full API response:

$ osapi client container docker create --image nginx:latest --json

Flags

FlagDescriptionDefault
--imageContainer image reference (required)
--nameOptional name for the container
--envEnvironment variable in KEY=VALUE format (repeatable)[]
--portPort mapping in host:container format (repeatable)[]
--volumeVolume mount in host:container format (repeatable)[]
--auto-startStart the container immediately after creationtrue
-T, --targetTarget: _any, _all, hostname, or label (group:web)_any
-j, --jsonOutput raw JSON response