liveBook · Manning

Batch scripting

As explained in Learn Docker in a Month of Lunches, Second Edition

A batch script is a text file containing commands for execution by a command interpreter, especially on Windows.

A batch script is a text file containing command-line instructions. In CI, it packages Docker Compose work into a repeatable script that developers can run locally and Jenkins can execute in Windows or Linux containers. section 11.4

A practical CI batch-script workflow is:

  • Store the script beside the application, Dockerfiles, and Compose files. section 11.4
  • Make the .bat file executable when the pipeline requires it. section 11.4
  • Run docker compose with the required files and --pull, then inspect captured build logs. section 11.4
Listing 11.5 Jenkinsfile build step that describes the CI job
# the build stage in the Jenkinsfile- it switches directory, then runs two
# shell commands - the first sets up a script file so it can be executed
# and the second calls the script:

stage('Build') {
  steps {
    dir('ch11/exercises') {
      sh 'chmod +x ./ci/01-build.bat'
      sh './ci/01-build.bat'
      }
  }
}

# and this is what's in 01-build.bat script:
docker compose
  -f docker-compose.yml
  -f docker-compose-build.yml
  build --pull

Use the listing to compare the Jenkins build step with the commands inside 01-build.bat. section 11.4

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Demonstrates script placement, execution, Docker Compose invocation, and log inspection without exploring batch-language syntax.
Examples
Uses 01-build.bat to run docker compose build --pull through a Jenkinsfile and inspect Jenkins build logs.
What you can do after
Apply it via Jenkins and Docker Compose to run consistent container builds and capture their output.
How it connects
Connects batch scripting with Docker Compose, Jenkins, continuous integration, containers, and source control.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.