Pi Docs
  • Overview
  • What is Pi
  • How It Works
  • Benefits
  • Features
  • Pricing
  • Quota and Limits
  • FAQ
  • Quickstart
    • Install CLI
    • Launch Your First Pod
    • Understand the network
    • Use Volume for Stateful Workload
    • Use Private Image
  • Feature
    • Pod
    • Rootfs
    • Job
    • Volume
    • Floating IP
    • Network
    • Service
    • Secret
    • Region and Zone
  • Reference
    • CLI
      • Info
      • Pod
        • run
        • create
        • delete
        • exec
        • logs
        • get
        • describe
      • Job
        • create
        • delete
        • get
        • describe
      • Service
        • create
        • get
        • describe
        • delete
      • Secret
        • create
        • get
        • describe
        • delete
      • Volume
        • create
        • get
        • delete
      • Floating IP
        • create
        • get
        • name
        • delete
    • API/v1.9
      • Info
        • Get
      • Event
        • Get
      • Pod
        • Create
        • List
        • Read
        • Log
        • Exec
        • Delete
      • Job
        • Create
        • List
        • Read
        • Delete
      • Service
        • Create
        • List
        • Get
        • Delete
      • Secret
        • Create
        • List
        • Get
        • Delete
      • Volume
        • Create
        • List
        • Get
        • Delete
      • Floating IP
        • Create
        • List
        • Get
        • Name
        • Delete
  • FAQ
    • Privacy Policy
    • Terms of Service
    • Acceptable Use Policy
  • Docs version
Powered by GitBook
On this page
  1. Reference
  2. CLI
  3. Pod

exec

Execute command in container

Usage: pi exec POD [OPTIONS] [-c CONTAINER] -- COMMAND [args...]

Execute a command in a container

          -e, --access-key                API access key
          -k, --secret-key                API secret key
          -r, --region                    Region name, default: gcp-us-central1
          -u, --user                      Username
          -c, --container                 Container name. If omitted, the first container in the pod will be chosen
          -i, --stdin                     Pass stdin to the container
          -t, --tty                       Stdin is a TTY

If no container specified, the command will be executed in the first container defined in the pod spec.

$ pi exec multiple-busybox-alpine -c alpine -- ping -c3 35.226.x.x
PING 35.226.x.x (35.226.x.x): 56 data bytes
64 bytes from 35.226.x.x: seq=0 ttl=64 time=2.075 ms
64 bytes from 35.226.x.x: seq=1 ttl=64 time=1.600 ms
64 bytes from 35.226.x.x: seq=2 ttl=64 time=2.009 ms
...

$ pi exec -it mysql -c mysql -- bash
root@mysql:/# uname -r
4.12.4-hyper
root@mysql:/# exit
PreviousdeleteNextlogs

Last updated 7 years ago