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:

  • Rspec test failing against Docker container
  • Gitlab CI: How to run tests in pipeline using docker and shell runner
  • Docker Elasticsearch Plugin with Request
  • Remote `docker-compose build`: workaround slow connections
  • getting python and react component based container to work
  • How to deploy an Dockerized Java/Widlfly Swarm Fat Jar Microservice + Database
  • $ 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.

  • Multilayer Docker Deployment on AWS
  • Run multiple services inside one docker container [closed]
  • Can I mount same volume to multiple docker containers
  • How to launch my docker container automatically on ECS?
  • Docker Use LXC with Direct Host Networking
  • How to properly configure the DNS configuration of the VirtualBox to resolve docker containers hostnames within the local network?
  • 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.