0

I'm new to realm of shell scripting and docker. I'm trying to run a shell script inside of a docker container to host.

Once the script inside my docker container has executed I want to run another script from host in new terminal without exiting my docker container.

I have written:

exit 0 > $?
if [ $? -eq 0 ]; then
echo $?
gnome-terminal --tab -x ./org3Added.sh
fi 

but this is not working.

James Z
  • 12,209
  • 10
  • 24
  • 44
Shalabh Negi
  • 621
  • 7
  • 18
  • You could use volumes to mount a directory to your docker container (docs: https://docs.docker.com/engine/admin/volumes/volumes/), once you run your script in the docker container, make it create a file in the file system. On the host machine you could watch the mounted directory for when this file appears and trigger the host script you want to run using (for inspiration: https://stackoverflow.com/questions/8699293/how-to-monitor-a-complete-directory-tree-for-changes-in-linux) – Pitt Jan 25 '18 at 07:21
  • I'm a bit unclear about what you're trying to achieve. Does the container do a bit of work and generate output that the host then uses in the script you are trying to call? – Richie Mackay Jan 25 '18 at 14:07
  • basically i'm trying to run a script on one terminal which will up my network, once our network is up without closing that terminal I have to open a new terminal which will run a new shell script (in that shell script i'm copying a shell script inside a docker container which will execute once i do "docker exec -it cli bash -rcfile /opt/script.sh") once this shell script inside docker is executed i will run a new script on new terminal which again start a new docker container and again a new script will run inside that docker container.Hope i was able to explain my self properly this time :) – Shalabh Negi Jan 29 '18 at 05:32

1 Answers1

1

The Docker container is a sandbox. In general you cannot directly run a script from inside the container that will execute on the host. The ideal way is to treat the host as a remote machine and ssh into it and execute the script.

You can however, grant the Docker container access to the host devices using the --privileged option

--privileged: Give extended privileges to this container
yamenk
  • 46,736
  • 10
  • 93
  • 87