- Get the ID of the container you want to SSH into
- SSH into the container you want
Docker containers can be a great way to try out some scripts before they are ready for production. One of the basic tasks is to run a command in a specific container. Here is how to do it.
Get the ID of the container you want to SSH into
You should get something like this:
SSH into the container you want
See the ID of the container you want to SSH into. In this case, I want the
joaorosilva/elasticsearch/elasticsearch:6.2.2 container. Insert the ID into the command:
You will get a
root command prompt.
If you want to run a different command, simply replace
/bin/bash with the command you want. Be aware that it will be run as