docker how do I make host scripts available inside a container

I am working with a kalilinux-based docker container (dnraikes/kali-net).
I am developing some proprietary scripts to run various security tools against our in-house servers so I don’t want to embed the scripts inside the docker image using either the COPY or ADD commands in my Dockerfile.

My scripts are in ~/scripts on the docker host.
when I run the docker container with the command:

  • How to set no-ack for RabbitMQ with docker?
  • FileNotFoundException in tomcat7 running inside a ubuntu docker container
  • Service host/port undefined, Kubernetes/Google Container Engine
  • Finding Docker container processes? from host point of view
  • Dockerhub fails to build my Dockerfile
  • Node.js - Error: [unixODBC] on db.open with Docker
  • $ docker run -it -v /opt/scripts:~/scripts dnraikes/kali-net /bin/bash
    

    Once inside the container, if I switch to /opt there is no scripts folder.

    Also, any results from the scripts must be visible on the docker host after the container has been either killed or stopped.

    What am I doing wrong.

  • Docker container can't connect to DB on external network
  • No module named torch, docker
  • Inside a Docker Container: “Error: cannot open display: localhost:11.0”
  • NLTK is not working in docker
  • Source code for Docker Swarm load balancer
  • Docker1.12 Worker not able to join in cluster(Swarm: Pending)
  • One Solution collect form web for “docker how do I make host scripts available inside a container”

    Try switching the directory locations like this:

    $ docker run -it -v /home/<username>/scripts:/opt/scripts dnraikes/kali-net /bin/bash
    

    From the documentation on volumes, -v takes [host-src]:[container-dest].

    Also note that host-src must be an absolute path so replace ~/scripts by /home/<username>/scripts or the full path to your scripts directory.

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