how to sync mac local directory with native docker container?

i am using native docker for mac and i have a small application running with docker container .

currently i am manually copying the data from my mac to docker container using docker cp command.

  • Docker nfs4 mount on Elastic Beanstalk
  • package.json file won't persist in docker container
  • run /usr/sbin/sshd in a Dockerfile does not work
  • Connecting Docker container to corporate LDAP server through SSL
  • “Could not find a version that satisfies the requirement cv2==1.0” when deploy Docker app with Anaconda and OpenCV to Heroku
  • How to list the content of a named volume in docker 1.9+?
  • i want to make it dynamic, i want to put the data in my local directory which should get sync with docker container .

    example:

    mac local dir : users/vishnu/data/
    

    which should get sync to

    `<Docker-container-ID>:/opt/deploy/`
    

    the container is already running ,i should not release the running container . i can only stop and start . is there a way ?? Thanks in advance

  • Dockerfile: COPY folder inside folder
  • Docker daemon and DNS
  • Docker stops immediately upon running - EOF error
  • Multiple docker containers of same image and memory usage
  • How to tag a docker container?
  • Redis Exited While Run With Persistent Data In Boot2Docker
  • One Solution collect form web for “how to sync mac local directory with native docker container?”

    host mounted volume.

    when you docker run you add a -v /Users/vishnu/data:/opt/deploy parameters.

    if you need to add a mounted volume to your existing container, use the Kitematic UI. it’s easier that way. but in general, you should add this when you docker run.

    also, FYI – the idea that you can’t delete a container is an anti-pattern with Docker. if you can’t delete your container, because it would cause too many problems, you’re doing something wrong. https://derickbailey.com/2017/04/05/what-i-learned-by-deleting-all-of-my-docker-images-and-containers/

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