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:

  • Docker workflow design with Jenkins on production
  • Can't run gdbserver in a Docker container for the Visual C++ for Linux Development
  • copying files using cp in dockfile fails
  • How to share a Docker container folder when it is not empty?
  • Chain automated builds in the same Docker Hub repository
  • Making REST calls to flask service running on different port
  • 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?

  • Most appropriate container for a data only container?
  • Should servlet running under tomcat in a container exit when it is not able to reach DB container?
  • harbor: login required for pulling open image
  • Docker dynamic load balancing with Nginx
  • Error Installing pip Inside Docker Container
  • Restart docker container from another 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.