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

411
Views
docker build con --build-arg con múltiples argumentos

De acuerdo con la documentación , es posible definir múltiples argumentos para el indicador --build-arg , pero no puedo averiguar cómo. Intenté lo siguiente:

 docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5 number_of_replicas=2 --no-cache .

=> Esto devuelve un error.

También probé:

 docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5,number_of_replicas=2 --no-cache .

=> Esto establece una variable, number_of_shards , al valor "5,number_of_replicas=2"

¿Alguna idea de cómo puedo definir múltiples argumentos?

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Use --build-arg con cada argumento.

Si está pasando dos argumentos, agregue --build-arg con cada argumento como:

 docker build \ -t essearch/ess-elasticsearch:1.7.6 \ --build-arg number_of_shards=5 \ --build-arg number_of_replicas=2 \ --no-cache .
over 4 years ago · Santiago Trujillo Report

0

La respuesta anterior de pl_rock es correcta, lo único que agregaría es esperar el ARG dentro del Dockerfile; de lo contrario, no tendrá acceso a él. Así que si estás haciendo

 docker build -t essearch/ess-elasticsearch:1.7.6 --build-arg number_of_shards=5 --build-arg number_of_replicas=2 --no-cache .

Luego, dentro del Dockerfile, debe agregar

 ARG number_of_replicas ARG number_of_shards

Me estaba encontrando con este problema, así que espero ayudar a alguien (a mí mismo) en el futuro.

over 4 years ago · Santiago Trujillo Report

0

Si desea utilizar la variable de entorno durante la compilación. Digamos establecer nombre de usuario y contraseña.

 username= Ubuntu password= swed24sw

Dockerfile

 FROM ubuntu:16.04 ARG SMB_PASS ARG SMB_USER # Creates a new User RUN useradd -ms /bin/bash $SMB_USER # Enters the password twice. RUN echo "$SMB_PASS\n$SMB_PASS" | smbpasswd -a $SMB_USER

Comando terminal

docker build --build-arg SMB_PASS=swed24sw --build-arg SMB_USER=Ubuntu . -t IMAGE_TAG

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!