inotifywait with Docker command and variable

I am trying to create a shell script that will check for a new file then cp to a Docker Container. The code I have so far is…

#!/bin/sh


source="/var/www/html/"
dest="dev_ubuntu:/var/www/html/"

inotifywait -m "/var/www/html" -e create -e moved_to |
while read file; do
    sudo docker cp /var/www/html/$file dev_ubuntu:/var/www/html
done

But this code gives the following error:

  • Install docker 1.2 on Amazon Linux AMI release 2014.03
  • Killbill on Google Flexible Environment using Java and Cloud SQL
  • Cannot connect from one container to another
  • Docker cannot start MongoDb with attached volume through data-only container
  • How to upload next version of code on amazon AWS which has docker instance?
  • Seeking advice on backend design for mobile app using AWS, Flask, and Docker
  • Setting up watches.
    Watches established.
    "docker cp" requires exactly 2 argument(s).
    See 'docker cp --help'.
    
    Usage:  docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
    docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH
    
    Copy files/folders between a container and the local filesystem
    

    What am I doing wrong?

  • Docker: Push data container onto Docker Hub
  • Get the containerID, docker
  • Why is SSH from inside docker container to other instance/server so slow
  • Tunnel Connection Failed error when logging into artifactory docker registry
  • How to open multiple terminals in docker?
  • docker how do I know if an update was pulled from repository
  • One Solution collect form web for “inotifywait with Docker command and variable”

    Do you have spaces in your file names? Use double quotes to avoid separating filenames by words:

    echo $file
    sudo docker cp "$file" dev_ubuntu:"$file"
    

    I’ve also echoed the file name to see what is happening.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.