Docker cheatsheet - Run commands in a container

Run commands in a container

docker exec

docker exec [options] CONTAINER COMMAND

Run a command in a running container
  -d, --detach        # run in background
  --detach-keys       # override the key sequence for detaching a container
  -i, --interactive   # stdin
  -t, --tty           # interactive
  -u, --user          # username or uid (format: <name|uid>[:<group|gid>])

Example

$ docker exec app_web tail logs/runtime.log
$ docker exec -t -i app_web rails c
Date: From:www.lautturi.com, cheatsheet