Skip to main content

Custom commands

How it works ?

As you can see in the .docker folder, there is a commands folder. This folder contains all the commands that you can run with the dcmd [command].

In fact, the dcmd command is just a wrapper around the docker-compose command. It will execute the command in the container that you want.

Also every available variables in the docker environment file can be used in your commands script.

Create a command

To create a command, you just need to create a file in the commands folder with the name of your command.

For example, if you want to create a command to run npm install in your container, you can create a file named npm in the commands folder.

.docker/commands/npm
#!/bin/bash

# @description: Run npm install in the container

TASK="$@"

docker exec ${PROJECT_NAME}_node npm $TASK

Template commands

Our templates come with several pre-configured useful commands that require no external dependencies. Do not hesitate to add your own commands to this folder or pick one as example to create your own.

For example in a Drupal project you can run the command below to import your database :

dcmd db-import ~/Desktop/my_awesome_db.sql

another exeample with params :

dcmd npm i --dev

Nested command

If you need several commands, separated by apps for example you can create a dir in the commands folder and execute commands as well :

dcmd my_first_app npm install
dcmd my_second_app npm install