If you want to explore containers file system it simply wan to get an access to containers shell, you can use one of the following options
Using the docker exec
command
Docker version 1.3 or newer supports the docker exec
command. This command can run the new process in an already running container. This means you can run bash /bin/bash
in the container state like this:
docker exec -t -i container_name /bin/bash
Using Snapshotting
You can peek into the docker file system by following these steps:
- Find the id of your running container
docker ps
- Create an image (snapshot) from the container file system
docker commit 12345678904b5 mysnapshot
- Explore the file system using the bash
docker run -t -i mysnapshot /bin/bash
This way, you can evaluate the filesystem of the running container at the precise time moment. The container is still running, no future changes are included.
To delete the snapshot, run the following command:
docker rmi mysnapshot
Using the ssh
If you want continuous access to the docker file system, you can install the sshd
to your container and run the sshd
daemon:
docker run -d -p 22 mysnapshot /usr/sbin/sshd -D
To see to which port to connect, run the following command:
docker ps
-
How To Deal With Persistent Storage (e.g. Databases) In Docker?
The best way to deal with persistent data storage (such as a database) in Docker is to use Docker’s volume API (for docker 1.9.0 or newer) or use data-only containers for older versions of Docker. ...
Questions -
Solved: Cron missing newline before EOF
This error may also happen when a crontab file is generated automatically and the generator failed to insert a newline character at the end of the crontab file.
Questions -
How Do I Pass Environment Variables to Docker Containers?
It is always a good practice to separate the app from its configuration. It is not a good idea to have a database login credential defined as variables in the code of the application. This is why w...
Questions -
Solved: Errors in crontab file, can't install
You may encounter this error while creating a new crontab or updating an existing one that has a syntax error.
Questions
Make your mark
Join the writer's program
Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.
Write for usBuild on top of Better Stack
Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.
community@betterstack.comor submit a pull request and help us build better products for everyone.
See the full list of amazing projects on github