How to open docker containers file system?

0 votes

I'm new to docker and I want to know how I can explore docker containers from the inside. Like what files exist inside of it. For Eg. when I download images from the docker index, I don't know what that image contains so it's impossible to start the application.

What should I do? Is there a way to SSH into them?

Jun 27 in Docker by shubham
• 6,870 points
23 views

1 answer to this question.

0 votes

There are various ways you can do this:

Method 1: Snapshoting

You can go through the container filesystem:

# find ID of your running container:
docker ps

# create image (snapshot) from container filesystem
docker commit 12345678904b5 mysnapshot

# explore this filesystem using bash (for example)
docker run -t -i mysnapshot /bin/bash

By doing this you can check the filesystem of running container in that moment in time. The container would still be in running condition with no future changes included.

After, you could delete this snapshot:

docker rmi mysnapshot

Method 2: SSH

If you want something continuous, you can use SSHD. You'll have to install it on your container and then execute SSHD Daemon:

 docker run -d -p 22 mysnapshot /usr/sbin/sshd -D

 # you need to find out which port to connect:
 docker ps

This way you'll be able to run you application using SSH.

Method 3: docker exec

If bash is present on your container you can directly use shell on your container by using:

docker exec -t -i mycontainer /bin/bash

Check Docker CLI documentation

answered Jun 27 by DareDev
• 6,810 points

Related Questions In Docker

+1 vote
2 answers

How to run docker containers on different machines

You can use labels and selectors for ...READ MORE

answered Oct 23, 2018 in Docker by Laila
57 views
0 votes
1 answer

How to obtain the Docker container's IP address from the host?

This can be done by executing the ...READ MORE

answered Jul 16, 2018 in Docker by Sophie may
• 9,430 points
200 views
0 votes
1 answer

How to remove old Docker containers

There is a new feature in Docker 1.13.x called Docker ...READ MORE

answered Jul 18, 2018 in Docker by Kalgi
• 2,620 points
27 views
0 votes
1 answer

How to list containers in Docker

To show only running containers use the given command: docker ...READ MORE

answered Jul 20, 2018 in Docker by Kalgi
• 37,320 points
25 views
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
• 56,160 points
99 views
0 votes
1 answer

How to send docker using terraform to aws cloudwatch?

Check if you set all the permissions ...READ MORE

answered Jun 7, 2018 in Docker by DareDev
• 6,810 points
316 views
+2 votes
6 answers

If conditional in docker file

You can use the test command RUN test ...READ MORE

answered Dec 10, 2018 in Docker by Shushant
10,393 views