I'm getting started working with Docker. I'm using the WordPress base image and docker-compose.
I'm trying to ssh into one of the containers to inspect the files/directories that were created during the initial build. I tried to run docker-compose run containername ls -la
, but that didn't do anything. Even if it did, I'd rather have a console where I can traverse the directory structure, rather than run a single command. What is the right way to do this with Docker?
Another option is to use nsenter.
To bash into a running container, type this:
Let's say, for reasons that are your own, you really do want to use SSH. It takes a few steps, but it can be done. Here are the commands that you would run inside the container to set it up...
Now you can even run graphical applications (if they are installed in the container) using X11 forwarding to the SSH client:
Here are some related resources:
SSH into a Docker container using this command:
docker exec
will definitely be a solution. An easy way to work with the question you asked is by mounting the directory inside Docker to the local system's directory.So that you can view the changes in local path instantly.
GOINSIDE SOLUTION
install
goinside
command line tool with:and go inside a docker container with a proper terminal size with:
old answer
We've put this snippet in
~/.profile
:Not only does this make everyone able to get inside a running container with:
It also solves a long lived problem about fixed Docker container terminal sizes. Which is very annoying if you face it.
Also if you follow the link you'll have command completion for your docker container names too.