Using Filecopy and SCP

This section describes how to copy files to and from a container (job instance) using the APC filecopy command and SCP (secure copy).

Using filecopy to transfer files

You can transfer files to and from an app, capsule, or job using apc <command> filecopy.

This command transfers a file securely to the specified container instance. If your environment is proxied, you should target your Apcera cluster over HTTPS before connecting to a container.

Note: jobs targeted with filecopy must have an scp binary installed and available in their $PATH to allow filecopy to work.

Capsule filecopy

Usage: apc capsule filecopy <capsule-name> <file-path> [optional-args]

Command options:

  -instance, --instance-id UUID      - UUID of the instance to transfer to

  -r, --remote-path PATH            - Path on the capsule for the file

  -dl, --download                   - Transfer file from the capsule to to your local machine.

Examples:

$ apc capsule filecopy mycapsule myfile

$ apc capsule filecopy mycapsule myfile -r ./path/remotefile -dl

If the capsule has more than one instance, one will be chosen to connect to. You may deterministically connect to the same instance by using the --instance flag, providing the UUID available from the apc job instances command. The apc job instances <job-name> command displays detailed information about the instances of a job, as well as its overall health score. For example:

$ apc job instances myjob
Looking up "myjob"... done
Health Score: 100%
Running Instances: 5/5
╭──────────┬─────────┬────────┬────────────────╮
│ UUID     │ Status  │ Uptime │ Host           │
├──────────┼─────────┼────────┼────────────────┤
│ 327164a8 │ RUNNING │ 32s    │ fancy-c8e18a4f │
│ b702a219 │ RUNNING │ 31s    │ fancy-c8e18a4f │
│ 4aada8be │ RUNNING │ 32s    │ fancy-c8e18a4f │
│ 17dbaf4b │ RUNNING │ 32s    │ fancy-c8e18a4f │
│ ccf976cc │ RUNNING │ 32s    │ fancy-c8e18a4f │
╰──────────┴─────────┴────────┴────────────────╯

Docker filecopy

The apc docker filecopy command transfers a file securely to the specified Docker job. If your environment is proxied, you should target your cluster over HTTPS before connecting to a Docker container.

Note: many common Docker images do not include an scp binary within the image, and do not allow filecopy as a result.

Usage: apc docker filecopy <job-name> <file-path> [optional-args]

Command options:

  -instance, --instance-id UUID      - UUID of the instance to transfer to

  -r, --remote-path PATH            - Path on the capsule for the file

  -dl, --download                   - Transfer file from the capsule to to your local machine.

For Docker jobs with more than one instance, docker filecopy will not reliably connect to the same instance. If your Docker job has more than one instance, one will be chosen to connect to. You may deterministically connect to the same instance by using the --instance flag, providing a UUID available from the apc job instances <job> command.

App filecopy

The app filecopy command transfers a file securely to the specified app. If your environment is proxied, you should target your Apcera cluster over HTTPS
before connecting to a app container.

Usage: apc app filecopy <app-name> <file-path> [optional-args]

Command options:

  -instance, --instance-id UUID      - UUID of the instance to transfer to

  -r, --remote-path PATH            - Path on the capsule for the file

  -dl, --download                   - Transfer file from the capsule to to your local machine.

For apps with more than one instance, app filecopy will not reliably connect to the same instance. If your app has more than one instance, one will be chosen to connect to. You may deterministically connect to the same instance by using the --instance flag, providing a UUID available from the apc app instances <job> command.

Job filecopy

The job filecopy command transfers a file securely to the specified job. If your environment is proxied, you should target your Apcera cluster over HTTPS before connecting to a job container.

Usage: apc job filecopy <job-name> <file-path> [optional-args]

Command options:

  -instance, --instance-id UUID      - UUID of the instance to transfer to

  -r, --remote-path PATH            - Path on the capsule for the file

  -dl, --download                   - Transfer file from the capsule to to your local machine.

For jobs with more than one instance, job filecopy will not reliably connect to the same instance. If your job has more than one instance, one will be chosen to connect to. You may deterministically connect to the same instance by using the --instance flag, providing a UUID available from the apc job instances command.

Using SCP to transfer files

Secure Copy (CP) is a protocol for securing transfering files.

If you have a more complicated setup and want to transer files using SCP, you can use the apc <job-type> pipe command.

Capsule pipe

The capsule pipe command opens an SSH session with the specified capsule. If your environment is proxied, you should target your Apcera cluster over HTTPS before connecting to a capsule. It is meant to be a replacement for ssh in commands like "scp" using the "-S" flag. To utilize this feature, create a script file which passes all command line arguments to it.

1) Create a script file with the following line:

apc capsule pipe "$@"

2) Then run the SCP command with the -S flag:

scp -S <myScript> <local-file> <capsule-name>:<remote-file>

For example:

scp -S ./myScript myfile mycapsule:myremotefile

Note that the script must be executable. To change the permissions, run chmod 777 <myScript>.

Docker pipe

The docker pipe command opens an SSH session with the specified docker application. If your environment is proxied, you should target your cluster over HTTPS before connecting to a Docker instance. It is meant to be a replacement for ssh in commands like "scp" using the "-S" flag. To utilize this feature, create a script file which passes all command line arguments to it.

1) Create a script file with the following line:

apc docker pipe "$@"

2) Then run the SCP command with the -S flag:

scp -S <myScript> <local-file> <docker-name>:<remote-file>

For example:

scp -S ./myScript myfile mydocker:myremotefile

App pipe

The app pipe command opens an SSH session with the specified app. If your environment is proxied, you should target your Apcera cluster over HTTPS before connecting to an app. It is meant to be a replacement for ssh in commands like "scp" using the "-S" flag.

1) Create a script file with the following line:

apc app pipe "$@"

2) Then run the SCP command with the -S flag:

scp -S <myScript> <local-file> <app-name>:<remote-file>

For example:

scp -S ./myScript myfile myapp:myremotefile

Job pipe

The job pipe command opens an SSH session with the specified job. If your environment is proxied, you should target your Apcera cluster over HTTPS
before connecting to a job. It is meant to be a replacement for ssh in commands like "scp" using the "-S" flag.

1) Create a script file with the following line:

apc job pipe "$@"

2) Then run the SCP command with the -S flag:

scp -S <myScript> <local-file> <job-name>:<remote-file>

For example:

scp -S ./myScript myfile myjob:myremotefile