How do I get into a Docker container?

0 votes

I recently 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?

Aug 10, 2018 in Docker by Hannah
• 18,060 points
114 views

1 answer to this question.

0 votes

docker attach will let you connect to your Docker container, but this isn't really the same thing as ssh. If your container is running a webserver, for example, docker attach will probably connect you to the stdout of the web server process. It won't necessarily give you a shell.

Use the docker exec command is probably what you are looking for; this will let you run arbitrary commands inside an existing container. For example:

docker exec -it <mycontainer> bash

answered Aug 10, 2018 by Kalgi
• 51,890 points

Related Questions In Docker

0 votes
2 answers

How do I copy a file from docker container to host?

Instead of using docker run you could ...READ MORE

answered Aug 13, 2019 in Docker by Sirajul
• 54,020 points
15,546 views
0 votes
2 answers

How do I run a docker image as a container?

You could probably follow these steps : $ docker ...READ MORE

answered Aug 9, 2019 in Docker by Sirajul
• 54,020 points
285 views
0 votes
1 answer

How do I start a Docker container with a volume?

You can first create the volume and ...READ MORE

answered Jul 2, 2019 in Docker by Namik
• 1,210 points
1,274 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 57,530 points
599 views
+3 votes
13 answers
0 votes
2 answers

How to edit file after I shell to a docker container?

You can even install it using a ...READ MORE

answered Apr 23, 2019 in Docker by Ashish
8,327 views