markmcdermott.io (js, ruby, ...etc) by mark mcdermott

Docker: Shell and Copy

Access shell in container and copy files

01/05/2025

read time:1 min

I’ve been learning Docker lately and learned a few new things last night: how to access a shell in a running container and how to copy files to and from a container.

Access Shell in Container

docker exec -it <container_name_or_id> sh

Copy File from Container

docker cp <container_name_or_id>:<path_in_container> <path_on_host>

Copy File to Container

docker cp <path_on_host> <container_name_or_id>:<path_in_container>