Skip to content

Instantly share code, notes, and snippets.

@rastislavcore
Created November 15, 2018 16:01
Show Gist options
  • Save rastislavcore/943b79d5b1b03e4659b5881857eabc5e to your computer and use it in GitHub Desktop.
Save rastislavcore/943b79d5b1b03e4659b5881857eabc5e to your computer and use it in GitHub Desktop.
Docker bash command

Docker

Assuming you know the name of your container, or if you don’t run docker ps to list the processes running and copy the container name…

Use either docker run or use docker exec with the -i (interactive) flag to keep stdin open and -t to allocate a terminal.

docker exec -i -t container_name /bin/bash

Or to run one or many commands:

docker exec -ti my_container sh -c "echo a && echo b"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment