Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

start docker toolbox from windows .bat file

I have installed Docker Toolbox on my Windows machine.

so when I need to start some Docker containers I:

  1. I start the Docker terminal (which starts the Docker virtual machine
  2. I use cd to command to go to the dir where I have some specific docker-compose.yml file
  3. I start the container using docker-compose up -d

can I have all of this in a .bat file so I just click and don't lose time typing the same everytime I need to start the container?

like image 265
Kupe3 Avatar asked Mar 22 '26 01:03

Kupe3


1 Answers

Create a .bat file with following content:

@echo off 
setlocal 
"%GIT_INSTALL_ROOT%\bin\bash.exe" --login -i "%DOCKER_TOOLBOX_INSTALL_PATH%\start.sh" 
"%PROJECT_LOCATION%/yourDockerComposeCommandsHere.sh

And the yourDockerComposeCommandsHere.sh file with commands you would like to run.

e.g.

#!/bin/sh
cd $PROJECT_LOCATION
docker-compose up -d ...
docker-compose up -d ...
docker-compose up -d ...

Do not forget to setup environment variables: GIT_INSTALL_ROOT, DOCKER_TOOLBOX_INSTALL_PATH, PROJECT_LOCATION.

like image 100
Sergey Krasnikov Avatar answered Mar 23 '26 19:03

Sergey Krasnikov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!