Home Arrow Icon Knowledge base Arrow Icon Global Arrow Icon How do I update the docker-compose.yml file in Laravel Sail


How do I update the docker-compose.yml file in Laravel Sail


To update the `docker-compose.yml` file in Laravel Sail, you can follow these steps:

1. Stop the running Sail containers:

Before making any changes to the `docker-compose.yml` file, it's recommended to stop the currently running Sail containers. You can do this by running:


   sail down
   

2. Open the `docker-compose.yml` file:

The `docker-compose.yml` file is located at the root of your Laravel project. You can open it using your preferred text editor.

3. Make the desired changes:

Update the `docker-compose.yml` file according to your requirements. This could include modifying existing service configurations, adding new services, or changing environment variables.

For example, if you want to update the MySQL service configuration, you can modify the `mysql` service block in the `docker-compose.yml` file:

yaml
   mysql:
     image: 'mysql:8.0'
     ports:
       - '${FORWARD_DB_PORT:-3306}:3306'
     environment:
       MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}'
       MYSQL_DATABASE: '${DB_DATABASE}'
       MYSQL_USER: '${DB_USERNAME}'
       MYSQL_PASSWORD: '${DB_PASSWORD}'
       MYSQL_ALLOW_EMPTY_PASSWORD: 'yes'
     volumes:
       - 'sailmysql:/var/lib/mysql'
   

4. Save the changes:

After making the desired modifications, save the `docker-compose.yml` file.

5. Rebuild the Sail containers:

To apply the changes you made to the `docker-compose.yml` file, you need to rebuild the Sail containers. You can do this by running:


   sail build
   

This command will rebuild the Docker images based on the updated `docker-compose.yml` file.

6. Start the updated Sail containers:

Finally, start the updated Sail containers using:


   sail up -d
   

The `-d` flag runs the containers in detached mode, allowing you to continue using the terminal.

That's it! You have successfully updated the `docker-compose.yml` file in your Laravel Sail environment. The changes you made will be applied to the rebuilt and restarted Sail containers.

Remember to consult the official Docker Compose documentation for more information on the available configuration options and best practices when modifying the `docker-compose.yml` file.

Citations:
[1] https://demos.pixinvent.com/materialize-vuejs-admin-template/documentation/guide/laravel-integration/laravel-sail-docker.html
[2] https://stackoverflow.com/questions/75305456/no-docker-compose-yml-when-installing-laravel-project
[3] https://demos.pixinvent.com/vuexy-vuejs-admin-template/documentation/guide/laravel-integration/laravel-sail-docker.html
[4] https://www.digitalocean.com/community/tutorials/how-to-install-and-set-up-laravel-with-docker-compose-on-ubuntu-22-04
[5] https://tenancyforlaravel.com/docs/v3/integrations/sail/