admin/ April 24, 2017/ Docker, Linux/ 0 comments

Docker build own Image using Bitrise CI/CD tool

You need three account to automate the Docker image build process.

1. Github ( or Bitbucket (
2. Dockerhub (
3. Bitrise (

1. Github/Bitbucket

SignUp or Login in the Github/Bitbucket. Create an repository.

Configure the Github/Bitbucket on you local system.

Step 1:
Create a directory and configure as below.

mkdir FirstRepo
cd FirstRepo
echo "# FirstRepo" >>
git init
git add
git commit -m "first commit"
git remote add origin [email protected]:username/FirstRepo.git
git push -u origin master

Create a file named as “Dockerfile”. Write you docker command statement inside the file which you want to build.
For Example-:

touch Dockerfile

Open your Dockerfile and paste the below line of statement.
To open Dockerfile on Linux

vi Dockerfile

Paste the below lines in the Dockerfile

FROM ubuntu:latest
MAINTAINER Arvind Rawat <[email protected]>

#Package install 
RUN apt update 
RUN apt install -y nginx

#Expose port to be used

#Run nginx
CMD ["nginx", "-g", "daemon off;"]

To Save file, use below command for vi editor.


Step 2:

Commit the Dockerfile and push on the Github/Bitbucket.

$ git add .
$ git commit -a -m "commit message"
$ git push origin master

2. Dockerhub (

Login the goto dockerhub dashboard.

Step 1:

Go To setting to link the Github Account/Bitbucket Account.

Click on the Setting.

Click on the Link Accounts & Services

Select the access for the repository.

Finally Your Github Account is linked.

Step 2-:

Automate the Docker build.

Click on “Create Automated Build”

Select your Repository Connector

Create your Automated Build.


3. Bitrise (

Bitrise Setup for Automated build the Docker Image.

Step 1:

Login the Bitrise account.
Add you First App

Select Github/Bitbucket to use your repository.

Authenticate your Repository.

Type your branch name if you used except the Master branch.

Validation the Repository

Select the Other/Manual

Use the Stack Selector as “Android $ Docker Ubuntu 16.04”

Register The Webhook.

Click on the Finsh Button on the Right hand on the top button.

Step 2:

Click on the App then open the “Workflow”

Open the Bitrise.yml

Paste the below lines in the bitrise,yml file.

format_version: 1.3.1
 is_expand: true
 is_expand: true
 is_expand: true
- push_branch: "*"
 workflow: primary
- pull_request_source_branch: "*"
 workflow: primary
 - [email protected]:
 run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
 - [email protected]: {}
 - [email protected]:
 title: Do anything with Script step
 - content: |-
 # fail if any commands fails
 set -e
 # debug log
 set -x
 # Docker login
 docker login -u "${DOCKER_LOGIN_USER}" -p "${DOCKER_LOGIN_PASS}"

 #Docker build the Dockerfile in Current Repository
 docker build -t $DOCKERHUB_IMG_ID .

 #Docker pushing the image on Dockerhub logged in account.
 docker push $DOCKERHUB_IMG_ID

 #Docker image removed from bitrise
 docker rmi $DOCKERHUB_IMG_ID

Step 3:

Secret Environment Variables

Fill the docker username in right textbox

Enter the Dockerhub Password.

Enter the Docker image as “Username/RepoName” as in the dockerhub account.

For Example -;

Finally your Bitrise automated Build Docker Image setup has been done.

Click on the Start build after build succeed check the tags in your the Dockerhub.

On the Success of the build Complete.


Check the final image in the Dockerhub tags.


Share this Post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.