Skip to content

Container Commands

Commands for managing containers

Create a new container

Usage:

Terminal window
container create [<options>] <image> [<arguments> ...]

Options:

  • -w, --cwd, --workdir <cwd> - Current working directory for the container
  • -e, --env <env> - Set environment variables
  • --env-file <env-file> - Read in a file of environment variables
  • --uid <uid> - Set the uid for the process
  • --gid <gid> - Set the gid for the process
  • -i, --interactive - Keep Stdin open even if not attached
  • -t, --tty - Open a tty with the process
  • -u, --user <user> - Set the user for the process
  • -c, --cpus <cpus> - Number of CPUs to allocate to the container
  • -m, --memory <memory> - Amount of memory in bytes, kilobytes (K), megabytes (M), or gigabytes (G) for the container, with MB granularity (for example, 1024K will result in 1MB being allocated for the container)
  • -d, --detach - Run the container and detach from the process
  • --entrypoint <entrypoint> - Override the entrypoint of the image
  • --mount <mount> - Add a mount to the container (type=<>,source=<>,target=<>,readonly)
  • --publish-socket <publish-socket> - Publish a socket from container to host (format: host_path:container_path)
  • --tmpfs <tmpfs> - Add a tmpfs mount to the container at the given path
  • --name <n> - Assign a name to the container. If excluded will be a generated UUID
  • --remove, --rm - Remove the container after it stops
  • --os <os> - Set OS if image can target multiple operating systems (default: linux)
  • -a, --arch <arch> - Set arch if image can target multiple architectures (default: arm64)
  • -v, --volume <volume> - Bind mount a volume into the container
  • -k, --kernel <kernel> - Set a custom kernel path
  • --network <network> - Attach the container to a network
  • --cidfile <cidfile> - Write the container ID to the path provided
  • --no-dns - Do not configure DNS in the container
  • --dns <dns> - DNS nameserver IP address
  • --dns-domain <dns-domain> - Default DNS domain
  • --dns-search <dns-search> - DNS search domains
  • --dns-option <dns-option> - DNS options
  • -l, --label <label> - Add a key=value label to the container
  • --scheme <scheme> - Scheme to use when connecting to the container registry. One of (http, https, auto) (default: auto)

Aliases: rm

Delete one or more containers

Usage:

Terminal window
container delete [--force] [--all] [--debug] [<container-ids> ...]

Options:

  • -f, --force - Force the removal of one or more running containers
  • -a, --all - Remove all containers

Run a new command in a running container

Usage:

Terminal window
container exec [--cwd <cwd>] [--env <env> ...] [--env-file <env-file> ...] [--uid <uid>] [--gid <gid>] [--interactive] [--tty] [--user <user>] [--debug] <container-id> <arguments> ...

Options:

  • -w, --cwd, --workdir <cwd> - Current working directory for the container
  • -e, --env <env> - Set environment variables
  • --env-file <env-file> - Read in a file of environment variables
  • --uid <uid> - Set the uid for the process
  • --gid <gid> - Set the gid for the process
  • -i, --interactive - Keep Stdin open even if not attached
  • -t, --tty - Open a tty with the process
  • -u, --user <user> - Set the user for the process

Display information about one or more containers

Usage:

Terminal window
container inspect [--debug] <containers> ...

Kill one or more running containers

Usage:

Terminal window
container kill [--signal <signal>] [--all] [<container-ids> ...] [--debug]

Options:

  • -s, --signal <signal> - Signal to send the container(s) (default: KILL)
  • -a, --all - Kill all running containers

Aliases: ls

List containers

Usage:

Terminal window
container list [--all] [--quiet] [--format <format>] [--debug]

Options:

  • -a, --all - Show stopped containers as well
  • -q, --quiet - Only output the container ID
  • --format <format> - Format of the output (values: json, table) (default: table)

Fetch container stdio or boot logs

Usage:

Terminal window
container logs [--debug] [--follow] [--boot] [-n <n>] <container>

Options:

  • -f, --follow - Follow log output
  • --boot - Display the boot log for the container instead of stdio
  • -n <n> - Number of lines to show from the end of the logs. If not provided this will print all of the logs

Run a container

Usage:

Terminal window
container run [<options>] <image> [<arguments> ...]

Options:

  • -w, --cwd, --workdir <cwd> - Current working directory for the container
  • -e, --env <env> - Set environment variables
  • --env-file <env-file> - Read in a file of environment variables
  • --uid <uid> - Set the uid for the process
  • --gid <gid> - Set the gid for the process
  • -i, --interactive - Keep Stdin open even if not attached
  • -t, --tty - Open a tty with the process
  • -u, --user <user> - Set the user for the process
  • -c, --cpus <cpus> - Number of CPUs to allocate to the container
  • -m, --memory <memory> - Amount of memory in bytes, kilobytes (K), megabytes (M), or gigabytes (G) for the container, with MB granularity (for example, 1024K will result in 1MB being allocated for the container)
  • -d, --detach - Run the container and detach from the process
  • --entrypoint <entrypoint> - Override the entrypoint of the image
  • --mount <mount> - Add a mount to the container (type=<>,source=<>,target=<>,readonly)
  • --publish-socket <publish-socket> - Publish a socket from container to host (format: host_path:container_path)
  • --tmpfs <tmpfs> - Add a tmpfs mount to the container at the given path
  • --name <n> - Assign a name to the container. If excluded will be a generated UUID
  • --remove, --rm - Remove the container after it stops
  • --os <os> - Set OS if image can target multiple operating systems (default: linux)
  • -a, --arch <arch> - Set arch if image can target multiple architectures (default: arm64)
  • -v, --volume <volume> - Bind mount a volume into the container
  • -k, --kernel <kernel> - Set a custom kernel path
  • --network <network> - Attach the container to a network
  • --cidfile <cidfile> - Write the container ID to the path provided
  • --no-dns - Do not configure DNS in the container
  • --dns <dns> - DNS nameserver IP address
  • --dns-domain <dns-domain> - Default DNS domain
  • --dns-search <dns-search> - DNS search domains
  • --dns-option <dns-option> - DNS options
  • -l, --label <label> - Add a key=value label to the container
  • --scheme <scheme> - Scheme to use when connecting to the container registry. One of (http, https, auto) (default: auto)
  • --disable-progress-updates - Disable progress bar updates

Start a container

Usage:

Terminal window
container start [--attach] [--interactive] [--debug] <container-id>

Options:

  • -a, --attach - Attach STDOUT/STDERR
  • -i, --interactive - Attach container’s STDIN

Stop one or more running containers

Usage:

Terminal window
container stop [--all] [--signal <signal>] [--time <time>] [<container-ids> ...] [--debug]

Options:

  • -a, --all - Stop all running containers
  • -s, --signal <signal> - Signal to send the container(s) (default: SIGTERM)
  • -t, --time <time> - Seconds to wait before killing the container(s) (default: 5)