Importing the sample data into a Docker volume

Create a new Docker volume, then import sample data into the volume.

About this task

Procedure

  1. Create the Docker volume for the sample data directory:
    docker volume create <volume name>
    For example, to create a volume named sample-data:
    docker volume create sample-data
  2. Use a temporary Docker container to import the sample data:
    docker run --rm -i --user="0:0" -v <volume name>:/local/notesdata \
      --entrypoint "/bin/bash" <image> \
      -c "cd /local/notesdata; tar xjf - <&0; chown -R notes:notes /local/notesdata" < <tar archive file>
    Where:
    This command starts a volt-docker container in bash mode and sequentially executes three shell commands:
    • cd /local/notesdata changes to the /local/notesdata directory.
    • tar xjf - <&0 extracts the tar archive file from stdin.
    • chown -R notes:notes /local/notesdata changes the ownership of all files in /local/notesdata.
    For example, the following command imports sample data from renovations-data.tbz2 into a volume named sample-data:
    docker run --rm -i --user="0:0" -v sample-data:/local/notesdata \
      --entrypoint "/bin/bash" volt-docker:V1101-1.0.0.11 \
      -c "cd /local/notesdata; tar xjf - <&0; chown -R notes:notes /local/notesdata" < renovations-data.tbz2
  3. The sample data is imported into the volume. Then the temporary Docker container stops and is automatically removed.