How to Copy Files from Docker Container to Local Disk

How to Copy Files from Docker Container to Local Disk

Postby yiboj » Thu Apr 26, 2018 4:28 pm

One question is often asked by users is how to copy data files from Docker container into local directory after the data files are generated dynamically in the container, such as the dataset_subsetting container. The dataset_subsetting container is created from the PODAAC dataset_subsetting image in Docker Hub. Here we use the dataset_subsetting image as an example to demonstrate the steps.

1. Download the dataset_subsetting image from docker
the image will be downloaded using the following command once the user has registered in the Docker Hub.
Code: Select all
docker pull podaacdatarecipes/dataset_subsetting


2. Run the dataset_subsettingimage with container
Code: Select all
docker run -it dataset_subsetting /bin/bash


3. Run the python subsetting script to subsetting and download dataset
Code: Select all
jovyan@e509a9143b1c:~$ ls
podaac_data_recipes
jovyan@e509a9143b1c:~$ cd podaac_data_recipes/
jovyan@e509a9143b1c:~/podaac_data_recipes$ ls
dataset_subset.ipynb  __pycache__  subset_dataset.py
jovyan@e509a9143b1c:~/podaac_data_recipes$ ./subset_dataset.py -s 20100101 -f 20100201 -b -140 -110 20 30 -x MUR-JPL-L4-GLOB-v4.1

Please wait while program searching for the granules ...


Longitude range: -140.000000 to -110.000000
Latitude range: 20.000000 to 30.000000
  every 1 pixel(s) is obtained

grid dimensions will be ( 3002 x 1002 )

OK to download?  [yes or no]: yes
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.9M    0 22.9M    0     0  15.8M      0 --:--:--  0:00:01 --:--:-- 15.8M
20100101090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc download finished !
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.9M    0 22.9M    0     0  5630k      0 --:--:--  0:00:04 --:--:-- 5632k
20100102090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc download finished !
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.9M    0 22.9M    0     0  7172k      0 --:--:--  0:00:03 --:--:-- 7173k
20100103090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc download finished !
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.9M    0 22.9M    0     0  10.1M      0 --:--:--  0:00:02 --:--:-- 10.1M
20100104090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc download finished !
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.9M    0 22.9M    0     0  14.4M      0 --:--:--  0:00:01 --:--:-- 14.4M
20100105090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc download finished !
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 22.9M    0 22.9M    0     0  15.8M      0 --:--:--  0:00:01 --:--:-- 15.8M


4. Check the data files created by script
Code: Select all
jovyan@e509a9143b1c:~/podaac_data_recipes$ ls
20100101090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100102090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100103090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100104090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100105090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100106090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100107090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100108090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100109090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100110090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100111090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100112090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100113090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100114090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100115090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100116090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100117090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100118090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100119090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100120090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100121090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100122090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100123090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100124090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100125090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100126090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100127090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100128090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100129090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100130090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
20100131090000-JPL-L4_GHRSST-SSTfnd-MUR-GLOB-v02.0-fv04.1_subset.nc
dataset_subset.ipynb
__pycache__
subset_dataset.py


5. Copy the nc data files to local disk
Open another terminal (don't exit from the container, the data files will lost without saving first), and execute the following command to copy the whole directory to the local disk. Here e509a9143b1c is the container ID.
Code: Select all
% docker cp e509a9143b1c:/home/jovyan/podaac_data_recipes/ .
yiboj
 
Posts: 80
Joined: Mon Mar 30, 2015 11:22 am

Return to Data Recipes

cron