Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

406
Views
Docker: Unable to run shell script stored in a mounted volume

I am running Docker (1.10.2) on Windows. I created a script to echo 'Hello World' on my machine and stored it in C:/Users/username/MountTest. I created a new container and mounted this directory (MountTest) as a data volume. The command I ran to do so is shown below:

docker run -t -i --name mounttest -v /c/Users/sarin/MountTest:/home ubuntu /bin/bash

Next, I run the command to execute the script within the container mounttest.

docker exec -it mounttest sh /home/helloworld.sh

The result is as follows:

: not foundworld.sh: 2: /home/helloworld.sh:
Hello World

I get the desired output (echo Hello World) but I want to understand the reason behind the not found errors.

Note: This question might look similar to Run shell script on docker from shared volume, but it addresses permission related issues.

References: The helloworld.sh file:

#!/bin/sh

echo 'Hello World'

The mounted volumes information is captured below. enter image description here

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Considering the default ENTRYPOINT for the 'ubuntu' image is sh -c, the final command executed on docker exec is:

sh -c 'sh /home/helloworld.sh'

It looks a bit strange and might be the cause of the error message.

Try simply:

docker exec -it mounttest /home/helloworld.sh
# or
docker exec -it mounttest sh -c '/home/helloworld.sh'

Of course, the docker exec should be done in a boot2docker ssh session, simalar to the shell session in which you did a docker run.
Since the docker run opens a bash, you should make a new boot2docker session (docker-machine ssh), and in that new boot2docker shell session, try the docker exec.

Trying docker exec from within the bash made by docker run means trying to do DiD (Docker in Docker). It is not relevant for your test.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!