Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

633
Views
Docker build specific local git branch

I am new to docker and would like to containerize a specific git branch of my app.If I run docker build and give the location of my dockerfile, an image will be build but from the local master branch by default.I want to be able to build another branch say "develop".I have done some research and all the answers I found suggest building from a specific remote branch and not a specific local branch.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You’d do this the same way you’d build or run any other program, from source, from a non-default branch: check out the branch you want to run locally, then run docker build.

git clone git@github.com:myname/project
cd project
git checkout branchname
docker build \
  -t myname/project:branchname-g$(git rev-parse --short HEAD) \
  .

(I need to do this fairly routinely in my day job: it lets me check out my colleague’s proposed feature branches and actually run them myself. Doing things like this, or trying to build a Docker image of yesterday’s code and not the thing that broke today, tends to be a pretty good reason to not git clone from within your Dockerfile.)

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!