---
title: "Create an exec instance"
method: POST
path: "/containers/{id}/exec"
tags: ["Exec"]
---

# Create an exec instance

`POST /containers/{id}/exec`

Run a command inside a running container.

## Path parameters

- `id` string, required

## Request body

- object
  - `AttachStdin` boolean — Attach to `stdin` of the exec command.
  - `AttachStdout` boolean — Attach to `stdout` of the exec command.
  - `AttachStderr` boolean — Attach to `stderr` of the exec command.
  - `ConsoleSize` integer[], nullable — Initial console size, as an `[height, width]` array.
  - `DetachKeys` string — Override the key sequence for detaching a container. Format is a single character `[a-Z]` or `ctrl-<value>` where `<value>` is one of: `a-z`, `@`, `^`, `[`, `,` or `_`.
  - `Tty` boolean — Allocate a pseudo-TTY.
  - `Env` string[] — A list of environment variables in the form `["VAR=value", ...]`.
  - `Cmd` string[] — Command to run, as a string or array of strings.
  - `Privileged` boolean — Runs the exec process with extended privileges.
  - `User` string — The user, and optionally, group to run the exec process inside the container. Format is one of: `user`, `user:group`, `uid`, or `uid:gid`.
  - `WorkingDir` string — The working directory for the exec process inside the container.

## Response `201`

no error

- IDResponse — Response to an API call that returns just an Id
  - `Id` string, required — The id of the newly created object.

## Other responses

- `404` — no such container
- `409` — container is paused
- `500` — Server error

---

[API](https://skmtc.net/chapar-rest/apis/docker-engine-api.md) · [All operations](https://skmtc.net/chapar-rest/apis/docker-engine-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/chapar-rest/docker-engine-api/versions/3a78a994dd0d/schema)
