Last active
March 11, 2019 10:04
-
-
Save ratulbasak/9bcb9dfa13b7f68f0af03d0201eed279 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os, sys | |
# wget -O - https://gist.githubusercontent.com/ratulbasak/9bcb9dfa13b7f68f0af03d0201eed279/raw/4c0101d7eeb5d353b0a2314b24c0f51cca1bf315/docker_cp.py | python | |
Project_ROOT = 'src' | |
ADAPTERS_FOLDER = "maindir" | |
directories = os.walk(os.getcwd()+'/'+Project_ROOT).next()[1] | |
def copy_from_docker(CONTAINER_NAME): | |
for dir in directories: | |
os.system("docker cp %s:/%s ./%s/%s" %(CONTAINER_NAME,dir,ADAPTERS_FOLDER,dir)) | |
print("./%s/%s copied done" % (ADAPTERS_FOLDER,dir)) | |
def del_create_dir(): | |
print("Recreating " + ADAPTERS_FOLDER) | |
os.rmdir(ADAPTERS_FOLDER) | |
os.makedirs(ADAPTERS_FOLDER) | |
# print(directories) | |
if __name__ == "__main__": | |
if os.path.isdir(ADAPTERS_FOLDER): | |
recreate = del_create_dir() | |
cp = copy_from_docker(sys.argv[1]) | |
else: | |
print("maindir not found") | |
os.makedirs(ADAPTERS_FOLDER) | |
cp = copy_from_docker(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment