Skip to content

Instantly share code, notes, and snippets.

@korya
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save korya/abd0785680e55dbd2696 to your computer and use it in GitHub Desktop.
Save korya/abd0785680e55dbd2696 to your computer and use it in GitHub Desktop.
Docker tricks

Exploring container's FS

First get a name or an ID of your docker container:

DOCKERID=$(docker ps | awk ...)

Quick and dirty

cd /var/lib/docker/aufs/mnt/$DOCKERID

Use nsenter

Install nsenter:

docker run -v /usr/local/bin:/target jpetazzo/nsenter

Then run:

nsenter --target $(docker inspect --format {{.State.Pid}} $DOCKERID) --mount

Take a snapshot

# create image (snapshot) from container filesystem
docker commit $DOCKERID mysnapshot

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

Refs

Attach to a docker container

nsenter --target $(docker inspect --format {{.State.Pid}} $DOCKERID) --mount --uts --ipc --net --pid

Refs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment