How to copy a folder from docker to other folder?

RUN cp /data/ /data/db, this command does not copy the files in /data to /data/db.

Is there an alternate way to do this?

  • Varnish/Symfony3 Cache on Nginx - Ago 0 on caching
  • Rails, Docker: Host does not exist: “default”
  • DigitalOcean: How to run Docker command on newly created Droplet via Java API
  • Docker - where are the src files for ADD and COPY?
  • Should I use AWS Elastic Beanstalk or the Amazon EC2 Container Service (ECS) to scale Docker containers?
  • SonarQube in Docker failes to resolve local host
  • Why does the new built image does not have the new installed package?
  • Launching multiple Docker containers with supervisor
  • Docker-Compose build failing on Google App Engine
  • Authentication is required error during automated build in docker hub
  • subdomain is created via domain regitrar or web server?
  • IdentityServer4: How to load Signing Credential from Cert Store when in Docker
  • One Solution collect form web for “How to copy a folder from docker to other folder?”

    It depends where /data is for you: already in the image, or on your host disk.

    A Dockerfile RUN command execute any commands in a new layer on top of the current image and commit the results.

    That means /data is the one found in the image as built so far.
    Not the /data on your disk.

    If you want to copy from your disk to the image /data/db folder, you would need to use COPY or ADD.

    At runtime, when you had an existing running container, you could also use docker cp to copy from or to a container.

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