Building a Docker image in Bamboo
In Bamboo, you can build a Docker image based on the specified Dockerfile. The Dockerfile may be provided as an existing file in the task's working directory or defined in the task configuration.
The image is stored in Docker's local image installation directory and can be used by subsequent Docker tasks in the job. You can optionally save the image to a file in the working directory which can then be packaged as a build artifact.
Before you begin
- Make sure you have Docker installed. We advise to use the most recent version.
Define a Docker capability in Bamboo. See Defining a new Docker capability
- If you're using Bamboo on Windows, you can't run Docker commands directly from the Windows command line. To use Docker tasks with Bamboo Windows, run Docker Machine.
To build a Docker image in Bamboo:
- In you job configuration screen, click Add task.
- Search for the Docker tasks type and select it.
- (optional) For future reference, add a Task description.
- (optional) Use the Disable this task checkbox to control whether your task gets run.
From the Repository drop-down list, choose Build a Docker image.
Complete the task settings.Build a Docker image...
The repository name (and optionally a tag) to be applied to the resulting image, following this pattern:
Use either an existing Dockerfile (located in the working directory for the task), or specify the contents of the Dockerfile.
Do not use cache when building the image
By default, Docker will reuse a cached build during the next build. See the Docker documentation.
Select Do not use cache... to ensure that the new image will include changes since the last build. Note that this may incur a performance penalty.
Save the image as a file
Specify the directory location and file name. Optionally configure a a job artifact to pass it to next stages and deployments. Advanced options (optional) Environment variables Additional system environment variables that you want to pass to your build. Note that existing environment variables are automatically available to the executable. You can also include Bamboo global or build-specific variables (see Bamboo variables).
Multiple variables should be separated with spaces. Parameters with spaces must be quoted (e.g JAVA_OPTS="-Xms200m -Xmx700m")
Working sub directory An alternative subdirectory, relative to the job's root directory, where Bamboo will run the executable. The root directory contains everything checked out from the job's configured source repository. If you leave this field blank, Bamboo will look for build files in the root directory. This option is useful if your task has a build script in a subdirectory and the executable needs to be run from within that subdirectory.