Home > database >  Run local script with arguments with docker
Run local script with arguments with docker

Time:01-27

I am trying to run a local script with docker bash in windows PowerShell but not working.

My script part is another program, but the finally goal is to process a media file and zip it with the shell script.

The cmd: docker exec -it containername /bin/bash < myscript.sh -f fileone.mp4 -h output

I have an error in ps: The '<' operator is reserved for future use.

The parameters (and also the files) are changing, if rerun the shell script, and after the script, processing is done it will create a zip file (what I need) with the output name, but random strings will be placed to the zipped filename too.

Anyone tried to use docker in that way in windows?

CodePudding user response:

I figure out a solution for my own question. I just leave it here, if someone needs it.

The docker-compose file:

version: '3.8'

services: 
  somename:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: 'name_if_you_need'

The dockerfile:

FROM debian:latest
# Install and/or config anything what you need
ADD . /newfolder
WORKDIR /newfolder 
ENTRYPOINT [ "/newfolder/myscript.sh" ] 

To call (with arguments and/or flags if your script need it): docker run --rm -v ${PWD}:/newfolder image_name -flag1 sample.mp4 -flag2 sample (no tty error, not need winpty)

Please note, if your script working with file or files, and you pass it via arguments like me, you need to copy them in your current folder before docker run

With this solution, if your script generates a file or files when/after executing, you will see them automatically in your current folder.

  •  Tags:  
  • Related