简体   繁体   中英

How to run local host machine script with arguments in a docker container

I'm trying to run a local script in my docker host on a docker container.

I know it is possible to run it using: docker exec -i mycontainer bash < mylocal.sh , but how do I pass arguments to the mylocal.sh using this method.

Say I want to pass the script contents plus an argument like mylocal.sh argument1

I don't really want to copy the files over from host to container.

您可以使用 -s 选项使用管道将参数传递给 bash 脚本。

docker exec -i mycontainer bash -s argument1 argument2 < mylocal.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM