How can I trigger a shell script which is available in local folder in linux to run through an API which is containerized .
Through docker container I want to trigger the shell script which is available in local folder
services:
webui:
image: sample/webui
container_name: webui
build:
context: .
dockerfile: Dockerfile
ports:
- 5000:5000
volumes:
- .:/usr/src/app:rw
networks:
- sampleApp
apis:
image: sample/apis
container_name: apis
build:
context: .
dockerfile: apis/Dockerfile
ports:
- 8686:8686
volumes:
- ..:/data/sw_data:rw
networks:
- sampleApp
networks: {sampleApp: {}}
volumes:
data:
2
Answers
You are trying to defeat original purpose of container: to isolate an app in the container from the rest of the system to protect the underlying host from any effect caused by the application in the container. You can do this though:
The container still have possibility to connect to port on the host. Listen on the host with simple server that would run the script.
If you are happy with just running the script that resides in the local folder, simply mount the folder to the container and run it from there.
You need to mount your script and then have to run it like below. Here I added two lines. One in volume and another is command. Volume will add script in docker and the command will run that script.