Tuesday, October 20, 2020

to copy a file from a docker container to host

shell>  docker cp <containerId>:/file/path/within/container /host/path/target


where to get your docker container id? 


shell> docker ps


and you will get to see similar output in your command prompt as following:


CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                    NAMES

fff29505492e        localstack_redis:latest        "docker-entrypoint.s…"   2 weeks ago         Up 8 hours          0.0.0.0:6379->6379/tcp   gifted_wozniak

2e99dabb5692        localstack_mysql:latest        "docker-entrypoint.s…"   2 weeks ago         Up 8 hours          0.0.0.0:3306->3306/tcp   vibrant_chandrasekhar

7438b2ef7cbb        localstack_prom2teams:latest   "sh prom2teams_start…"   2 weeks ago         Up 8 hours          8089/tcp                 cranky_merkle


Case : to copy a file in your docker location such as /tmp/target.txt from localstack_mysql:latest. 

shell> docker cp 2e99dabb5692:/tmp/target.txt c:/tmp/

No comments:

Post a Comment