Tag Archives: Docker Container

HOW TO COPY FILES FROM HOST TO DOCKER CONTAINER?

How to Copy files from host to Docker container?

The cp command can be used to copy files. One specific file can be copied like:
docker cp foo.txt mycontainer:/foo.txt
docker cp mycontainer:/foo.txt foo.txt

Multiple files contained by the folder src can be copied into the target folder using:
docker cp src/. mycontainer:/target
docker cp mycontainer:/src/. target

In order to copy a file from a container to the host, you can use the command
docker cp :/file/path/within/container /host/path/target

AWS CLI IN A DOCKER CONTAINER?

AWS CLI in a Docker Container?

Most of the systems we are using now have Docker on it. Here we will walk you through how to use the container and two of the many useful commands available to the AWS CLI tool.

Starting the Docker container:
It is pretty simple to start the Docker container and get a shell:

AWS CLI

Once you are in the shell, you can use any of the supported commands.  For example, you can copy/upload items to S3, list ec2 instances, and start ec2 instances.

Copy files to S3:

If you have set of files on your local server that you want to copy over to S3, you can use the tool to do that. I’ve written instructions for copying over files in /opt/database to s3://garland.public.bucket/database below.

First, you need to restart the container and map the directory you want to copy over.

Capture

This adds the Docker -v option which maps a path from your local server to inside the container.  The format is /local/path:/inside/cvontainer/path.