Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

234
Vistas
Using RUN command in Dockerfile on Windows and Linux

In my Dockerfile I have

FROM microsoft/dotnet:2.1-sdk
COPY devops/scripts/setup.sh .
RUN ls
RUN chmod +x ./setup.sh 
RUN ./setup.sh
WORKDIR /app

Step 3 I am using just to show that file is actually present.

When used in docker-compose this works perfectly on Linux, but when runnning docker-compose up on Windows it results in

> docker-compose up
Building create_template
Step 1/6 : FROM microsoft/dotnet:2.1-sdk
 ---> 511c1f563ce6
Step 2/6 : COPY devops/scripts/setup.sh .
 ---> 3d3bb4ab9bc4
Step 3/6 : RUN ls
 ---> Running in 43ad6e244ed8
bin
boot
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
setup.sh     <--- 
srv
sys
tmp
usr
var
Removing intermediate container 43ad6e244ed8
 ---> aa32210d6a87
Step 4/6 : RUN chmod +x ./setup.sh
 ---> Running in 2d6858495355
Removing intermediate container 2d6858495355
 ---> 5e0388623851
Step 5/6 : RUN ./setup.sh
 ---> Running in abb3a52fe6ec
/bin/sh: 1: ./setup.sh: not found
ERROR: Service 'create_template' failed to build: The command '/bin/sh -c ./setup.sh' returned a non-zero code: 127

Is there a way to use same dockerimage files and commands on both systems or do I have to have alternate dockerimage and docker-compose for each? Thank you

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I tried your example on windows & reproduce your problem.

The root cause is when you new the file setup.sh on windows, it's DOS format. You need to use git-bash or other similar to transfer the file format on host to unix format in advance before compose or build, something like:

dos2unix setup.sh

Another way is do it in Dockerfile, and this also compatible when you use linux host, something like next:

RUN apt-get update && apt-get install -y dos2unix && dos2unix setup.sh
RUN ./setup.sh
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda