Docker Managing containers Run command on an already existing docker container

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


docker exec -it <container id> /bin/bash

It is common to log in an already running container to make some quick tests or see what the application is doing. Often it denotes bad container use practices due to logs and changed files should be placed in volumes. This example allows us log in the container. This supposes that /bin/bash is available in the container, it can be /bin/sh or something else.

docker exec <container id> tar -czvf /tmp/backup.tgz /data
docker cp <container id>:/tmp/backup.tgz .

This example archives the content of data directory in a tar. Then with docker cp you can retrieve it.

Got any Docker Question?