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 recover from
  • Docker nginx container exists instantly
  • How do we set the the RAM and disk space for a docker container?
  • dumb-init No such file or directory
  • Executing containers on multiple architectures [closed]
  • Cant get AngularJS site running in Docker Container
  • $ 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.

  • How to access docker service with docker private ip and port from different host in aws without port forwarding or using docker host ip
  • How to SSH into running docker container from jenkins execute shell
  • Strange error about permissions inside a docker container
  • Install swagger-ui error
  • Migrate container from one machine to another machine
  • Clone server to docker image
  • 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.