Skip to content

Instantly share code, notes, and snippets.

@RubMart
Created July 19, 2018 16:52
Show Gist options
  • Save RubMart/90be2b08bca73cc89009e5d0cdcfe070 to your computer and use it in GitHub Desktop.
Save RubMart/90be2b08bca73cc89009e5d0cdcfe070 to your computer and use it in GitHub Desktop.
[Run bash or any command in a Docker container] Run bash or any command in a Docker container #docker #tips #tricks

Run bash or any command in a Docker container

Docker

Assuming you know the name of your container, can use

docker exec -it container_name /bin/bash

Know containers in execution and copy container id or container name to execute command

docker ps

Or execute any command

docker exec -it container_name pm2 --help

Docker Compose

The equivalent command in compose docker apps

docker-compose exec container_name sh

References

[1] Docker: exec [2] Docker compose: exec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment