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

597
Visualizações
¿Cómo crear index.html usando dockerfile?

Estoy tratando de crear una web estática simple usando nginx, y quiero que todo sea creado por Dockerfile, el problema es que cada vez que intento crear un archivo index.html, sale con error, incluso intenté probarlo y su trabajando con "index.htm" pero no con el formato correcto.

 FROM centos:7 #update and install nginx section RUN yum update -y RUN yum install -y epel-release RUN yum install -y nginx #create path and add index.html WORKDIR /usr/share/nginx/html #this one working with no issue RUN touch index.htm #this one will get failed RUN touch index.html EXPOSE 80/tcp CMD ["nginx", "-g", "daemon off;"]

y esta es la salida de error:

 majid@DESKTOP-39CBKO0:~/nginx_simple_web$ docker build -t simple-web:v1 . [+] Building 3.8s (11/11) FINISHED => [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 381B 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [internal] load metadata for docker.io/library/centos:7 3.4s => [auth] library/centos:pull token for registry-1.docker.io 0.0s => [1/7] FROM docker.io/library/centos:7@sha256:9d4bcbbb213dfd745b58be38b13b996ebb5ac315fe75711bd618426a630 0.0s => CACHED [2/7] RUN yum update -y 0.0s => CACHED [3/7] RUN yum install -y epel-release 0.0s => CACHED [4/7] RUN yum install -y nginx 0.0s => CACHED [5/7] WORKDIR /usr/share/nginx/html 0.0s => CACHED [6/7] RUN touch index.htm 0.0s => ERROR [7/7] RUN touch index.html 0.4s ------ > [7/7] RUN touch index.html: #11 0.357 touch: cannot touch 'index.html': No such file or directory ------ executor failed running [/bin/sh -c touch index.html]: exit code: 1 majid@DESKTOP-39CBKO0:~/nginx_simple_web$
over 4 years ago · Santiago Trujillo
4 Respostas
Responde à pergunta

0

debes crear un archivo y puedes usar

COPIAR index.html index.html

comando en Dockerfile para copiar un archivo en la imagen cuando se compila

o usar

echo " " > comando index.html para crear un archivo

over 4 years ago · Santiago Trujillo Relatório

0

Puede crear un nuevo archivo usando echo :

 RUN echo " " > index.htm
over 4 years ago · Santiago Trujillo Relatório

0

El archivo ya existe y es propiedad de root:

 RUN ls -al index.html ---> Running in 27f9d0ae6240 lrwxrwxrwx 1 root root 25 Dec 23 12:08 index.html -> ../../doc/HTML/index.html

eliminarlo y volver a crearlo:

 FROM centos:7 #update and install nginx section RUN yum update -y RUN yum install -y epel-release RUN yum install -y nginx RUN yum install -y vim #create path and add index.html WORKDIR /usr/share/nginx/html RUN rm index.html RUN touch index.html EXPOSE 80/tcp CMD ["nginx", "-g", "daemon off;"]

Tenga en cuenta que, en general, debe combinar varios comandos RUN juntos.

over 4 years ago · Santiago Trujillo Relatório

0

En su Dockerfile puede usar EJECUTAR RUN {command} como en la línea de comandos.

 RUN mkdir -p /home/foo/ RUN echo "Hello World" > /home/foo/index.html
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