![]() ![]() NOTE: This answer relies on commen tool being present, but if there is no bash shell or common tools like ls present you could first add one in a layer if you have access to the Dockerfile:Įxample for alpine: RUN apk add -no-cache bash Look for entrypoint or cmd in the json return. You might want to do this and find out if there is any bash or sh in there. This command should let you inspect a running docker container or image:ĭocker inspect name-of-container-or-image This command should let you explore a docker image: docker run -rm -it -entrypoint=/bin/bash name-of-image (web is the name-of-service in this case and it has tty by default.) The equivalent for this in docker-compose would be: docker-compose exec web bash This command should let you explore a running docker container: docker exec -it name-of-container bash The short version is: with nsenter, you can get a shell into anĮxisting container, even if that container doesn’t run SSH or any kind Use nsenter, see Why you don't need to run SSHd in your Docker containers This way, you can run your app using ssh (connect and execute what you want). # you need to find out which port to connect: If you need continuous access, you can install sshd to your container and run the sshd daemon: docker run -d -p 22 mysnapshot /usr/sbin/sshd -D You can later delete snapshot using (filesystem of the running container is not affected!): docker rmi mysnapshot Container is still running, no future changes are included. This way, you can evaluate filesystem of the running container in the precise time moment. # explore this filesystem using bash (for example) # create image (snapshot) from container filesystem You can evaluate container filesystem this way: # find ID of your running container: See Docker command line documentation B) Use Snapshotting You can run /bin/bash to explore container state: docker exec -t -i mycontainer /bin/bash This command can run new process in already running container (container must have PID 1 process running already). A) Use docker exec (easiest)ĭocker version 1.3 or newer supports the command exec that behave similar to nsenter. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |