docker cp moves files or directories between a container filesystem and the host in either direction. In CI it extracts artifacts such as compiled binaries, coverage reports, or screenshots from a container so a later step can upload them.
Common flags
docker cp CONTAINER:SRC DEST - copy from container to host
docker cp SRC CONTAINER:DEST - copy from host to container
After a containerized test run, docker cp the reports directory out to the workspace, then upload it as an artifact. cp works on stopped containers too, so you can extract output even from a container that has exited.
Key takeaways
cp copies in either direction between container and host.
It works on stopped containers, so you can extract output post-exit.
Common CI use is pulling coverage, reports, or binaries out for artifact upload.
Frequently asked questions
docker cp Command Reference?
docker cp moves files or directories between a container filesystem and the host in either direction. In CI it extracts artifacts such as compiled binaries, coverage reports, or screenshots from a container so a later step can upload them.
In CI?
After a containerized test run, docker cp the reports directory out to the workspace, then upload it as an artifact. cp works on stopped containers too, so you can extract output even from a container that has exited.