Search code examples
laraveldockerlaradock

Can I create single Dockerfile from laradock?


I got instructed to create a single dockerfile in the root of the project, but also got a tip to use the laradock as starting point.

How can I do this? The only way so far I know to create an docker environment is to run it with docker-compose command


Solution

  • No, Dockerfiles are single containers (services) by design. Laradock provides a docker-compose file that references multiple dockerfiles. However you could create a smaller docker-compose file that only starts the containers you need (let's say a webserver with php, a database server and redis).

    Laradock ships with way to much containers in docker-compose, that is why the tutorial tells you to specify which containers you want to run.

    docker-compose up -d nginx mysql
    

    But if you specify a minimal docker-compose.yml, you just can type

    docker-compose up -d
    

    without any additional arguments


    Yes, you could add all the required services to a single container, but that would be against what you try to achieve using Docker.