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?
Use:
The other way, albeit there is a danger to it, is to use
attach
, but if you Ctrl + C to exit the session, you will also stop the container. If you just want to see what is happening, usedocker logs -f
.Use this command:
To connect to cmd in a Windows container, use
Where d8c25fde2769 is the container id.
For docker-compose up (Docker4Drupal)
I use Docker for Drupal on a Linux laptop. After running the container I use '
docker-compose exec php bash
' to connect with the container so I can run drush commandos. It works fine for me.If you are using Docker Compose then this will take you inside a Docker container.
Inside the container it will take you to WORKDIR defined in the Dockerfile. You can change your work directory by
It is simple!
List out all your Docker images:
On my system it showed the following output:
I have two Docker images on my PC. Let's say I want to run the first one.
This will give you terminal control of the container. Now you can do all type of shell operations inside the container. Like doing
ls
will output all folders in the root of the file system.