Copying Files Between Host and Container

Onload User Guide (UG1586)

Document ID
UG1586
Release Date
2023-07-31
Revision
1.2 English

The following example demonstrates how to copy files from the host to a container. All commands are run on the host.

  1. Get the container Short Name (output truncated):
    [root@hostname]# docker ps -a
    CONTAINER ID
    bd1ea8d5526c
  2. Discover the container Long Name:
    [root@hostname]# docker inspect -f '{{.Id}}' bd1ea8d5526c
    bd1ea8d5526c55df4740de9ba5afe14ed28ac3d127901ccb1653e187962c5156

    The container long name can also be discovered using the container name in place of the container identifier.

  3. Copy a file to root file system (/tmp) on the container:
    [root@hostname]# cp myfile.txt /var/lib/docker/devicemapper/mnt/bd1ea8d5526c55df4740de9ba5afe14ed28ac3d127901ccb1653e187962c5156/rootfs/tmp/myfile.txt