How to use PID settings

Hi,

I’m trying to understand PID in docker. In documentation, this can be used to debug a container. I just wonder if you have any more specific examples on how/why/when to use this feature. This is the example that I’ve found in documentation, but I’m not really familiar with strace.

 docker run --name my-redis -d redis

Debug the redis container by running another container that has strace in it:

$ docker run -it --pid=container:my-redis my_strace_docker_image bash
$ strace -p 1

The normal way I see people debug a running container is to docker exec -it $CONTAINER sh and install their debug tools on-demand in the container. But what if your container doesn’t have /bin/sh? What if it doesn’t have a package manager? You could copy utilities into the container with docker cp and then exec into the running container but that’s also a hassle.

So instead of trying to debug from within the container.

Check a full article with an example here: