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

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

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 Relatório

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 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