Docker: Open a Bash Shell in a Docker Container Without SSH
You don’t need to install SSHd on your Docker containers.. However, the method you use has changed. Now Docker has the exec
command to do this for you.
If you have a container named my-app-container
then you would run:
$ docker exec -it my-app-container bash
To open a bash shell in your container.
As an added bonus, if you’re in development and you want to get into your Docker VM then the easiest way is to run:
$ docker-machine ssh [docker_vm_name]
For most of us using the default
VM it would look like this:
$ docker-machine ssh default
Once you’ve opened ssh
into your VM, then you can run the docker exec
command at the top.