Skip to content

Instantly share code, notes, and snippets.

@monocongo
Created June 14, 2019 15:34
Show Gist options
  • Save monocongo/582c43f3e3ec8d16b75ec3aa6fb02b7c to your computer and use it in GitHub Desktop.
Save monocongo/582c43f3e3ec8d16b75ec3aa6fb02b7c to your computer and use it in GitHub Desktop.
Commands for facilitating copy of files into a Docker container

Find the Docker container ID (from localhost bash):

$ export DOCKER_CONTAINER=`sudo docker ps -a --no-trunc -q`

If more than a single Docker container is running then get the PyTorch container ID by grepping pytorch from the docker ps -a output, then using the final value of the output (the container's name) we can get the container ID via docker inspect:

$ sudo docker ps -a | grep pytorch
6b525cb4a112        nvcr.io/nvidia/pytorch:19.05-py3   "/usr/local/bin/nvid…"   7 hours ago         Up 7 hours                              modest_austin
$ export DOCKER_CONTAINER=`sudo docker inspect --format="{{.Id}}" modest_austin`

Create a directory for our images dataset on the PyTorch Docker container:

$ export DOCKER_DATA_DIR=/root/data
$ mkdir $DOCKER_DATA_DIR
$ mkdir $DOCKER_DATA_DIR/images
$ mkdir $DOCKER_DATA_DIR/annotations

Copy images and annotations from the localhost into the PyTorch Docker container:

$ export DOCKER_DATA_DIR=/root/data
$ cd $DATA_DIR
$ sudo docker cp images/* $DOCKER_CONTAINER:$DOCKER_DATA_DIR/images
$ sudo docker cp annotations/* $DOCKER_CONTAINER:$DOCKER_DATA_DIR/annotations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment