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…



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

But this code gives the following error:

  • kubernetes replication controller
  • What work does the process in container “” do?
  • Prevent Docker-Engine restart during apt-get upgrade
  • Update odoo custom module using docker-compose
  • Docker - how to mount folder inside running container as volume to other running container? [closed]
  • Running gem install in a docker build hangs
  • Setting up watches.
    Watches established.
    "docker cp" requires exactly 2 argument(s).
    See 'docker cp --help'.
    Copy files/folders between a container and the local filesystem

    What am I doing wrong?

  • Starting Docker Container With Different Parameters
  • Docker Cloud Service Discovery Two Containers
  • Emulating Raspberry Pi with Docker on OS X
  • Can I run Xcode in a docker container?
  • Error 'import path does not begin with hostname' when building docker with local package
  • How does docker run differ from running a command from a shell within the container
  • 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.