Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

407
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda