Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

PetroGromovo's avatar

How in docker run command php artisan key:generate after composer install?

Hi all, having docker for laravel 6 app I run command

composer install

which is written in docker-compose.yml (version: '3') as:

  composer:
    container_name: project-composer
    image: composer:1.8
    volumes:
      - ".:/app"
    working_dir: "/app"
    command: composer install --ignore-platform-reqs

If there is a way after

composer install 

was succesfully run to run also command

php artisan key:generate

?

Thanks!

0 likes
2 replies
bobbybouwmann's avatar

You should be running that command either inside your application container or outside of your application container and have syncing set up within your docker-compose file.

It seems to me that you only have a composer container, but you need more than that to run a PHP project in Docker.

1 like
PetroGromovo's avatar

I have Dockerfile file where I install composer, npm, yarn, php extentions and different packages I need for my docker box(ex : nano, mc, curl , git)

Also I have docker-compose.yml with several containers defined(web, db, adminer and composer) and in the last container

    composer:
        container_name: hostels3_composer
        image: composer:1.8
        volumes:
            - ${APP_PATH_HOST}:${APP_PTH_CONTAINER}
        working_dir: ${APP_PTH_CONTAINER}
        command: composer install --ignore-platform-reqs

command - that is what run when all steps in Dockerfile are completed.

I wonder if there is a way to run other command(in my case php artisan key:generate) after

composer install

was cussesfully run and file /vendor/autoload.php was generated?

Please or to participate in this conversation.