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

452
Vistas
How to append command to docker-compose.yml without override existing?

In docker-compose.yml I have a service

app:
    image: yiisoftware/yii2-php:7.1-apache
    volumes:
      - ~/.composer-docker/cache:/root/.composer/cache:delegated
      - ./:/app:delegated
    ports:
      - '80:80'
    depends_on:
      - db

So I want to execute command yii migrate --interactive=0 when container is started. But if I just add string

command: "yii migrate --interactive=0"

It override command that already specified in yiisoftware/yii2-php:7.1-apache dockerfile. How can I append command, not replace? Is it possible?

I already googled for this problem, but most popular solution is "create your own dockerfile". Can I solve this without create/modify dockerfile or shell script, only with docker-compose?

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

0

To do this, you would have to define your own ENTRYPOINT in your docker-compose.yml. Besides building your own Dockerfile, there is no way around this.

As much as I am searching, I cannot find a CMD instruction in this image's Dockerfile, though. So this is probably what's being used.

I'm not familiar with PHP, so I cannot estimate what you would have to change to run a container with your specific needs, but these are the points that you should have a look at.

over 4 years ago · Santiago Trujillo Denunciar

0

You can include the pre-existing command in your new command. Now understand that everything in those commands can be called from sh or bash. So look up the existing command by doing an:

docker image inspect yiisoftware/yii2-php:7.1-apache

Then check the command in Config { Command }. (Not ConatinerConfig.) So if the existing command had been:

"start-daemon -z foo-bar"

then your new command would be:

sh -c "start-daemon -z foo-bar; yii migrate --interactive=0"

Now you'll have the existing command plus your new command and the desired effect.

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