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

451
Views
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 answers
Answer question

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 Report

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