3

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?

Sofyan Thayf
  • 1,322
  • 2
  • 14
  • 26
Kupe3
  • 371
  • 2
  • 5
  • 12
  • 1
    Yes, put all the commands that you would put into cmd into a .bat file and run it and fix whatever errors until it does what you want.... – PressingOnAlways Jul 30 '17 at 02:19
  • I can start the terminal, but dont know how to execute commands inside the terminal – Kupe3 Jul 30 '17 at 02:30

2 Answers2

2

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.

0

I tried to create a batch file starting the start.sh with full path, but that didn't work.

This worked for me: Given that Docker toolbox installed in C:\Program Files\Docker Toolbox, try the below procedure:

Put all these commands in a file called "Docker.cmd" on your desktop and run it as administrator.

cd\
cd "Program Files"
cd "Docker Toolbox"
start.sh
Mouli
  • 91
  • 1
  • 14