cp .env.example .env docker compose up -d docker compose exec <container_name> <command> docker compose exec <container_name> sh docker compose downThis script allows you to manage Docker containers easily. You can start containers with specified options or stop them with a simple command.
You can run the script with the following commands:
./script.sh [on|off] [-c=<comma-separated values>]
on: Starts the specified Docker containers.off: Stops all running Docker containers.-c=<comma-separated values>: Specifies which containers to start. If this flag is not provided, default containers will be used.
If you run the script with on without the -c flag, the following containers will be started by default:
nginxmysqlphp-fpmphp-workerportainerproxyworkspace
- Start default containers:
- Start specified containers:
- Stop all containers:
./script.sh on ./script.sh on -c=nginx,php ./script.sh off -c=nginx,php- Docker
- Docker Compose
-
Ensure that your
docker-compose.ymlfile is properly configured to support the containers you want to start. -
The script uses
evalto execute the generated Docker command, so please be cautious with the input values. -
Try using an alias to make it easier to run the script in any directory. 😉