window.pipedriveLeadboosterConfig = { base: 'leadbooster-chat.pipedrive.com', companyId: 11580370, playbookUuid: '22236db1-6d50-40c4-b48f-8b11262155be', version: 2, } ;(function () { var w = window if (w.LeadBooster) { console.warn('LeadBooster already exists') } else { w.LeadBooster = { q: [], on: function (n, h) { this.q.push({ t: 'o', n: n, h: h }) }, trigger: function (n) { this.q.push({ t: 't', n: n }) }, } } })() HOW TO DOCKER LESSON LEARNED - The Codest
The Codest
  • About us
  • Services
    • Software Development
      • Frontend Development
      • Backend Development
    • Staff Augmentation
      • Frontend Developers
      • Backend Developers
      • Data Engineers
      • Cloud Engineers
      • QA Engineers
      • Other
    • It Advisory
      • Audit & Consulting
  • Industries
    • Fintech & Banking
    • E-commerce
    • Adtech
    • Healthtech
    • Manufacturing
    • Logistics
    • Automotive
    • IOT
  • Value for
    • CEO
    • CTO
    • Delivery Manager
  • Our team
  • Case Studies
  • Know How
    • Blog
    • Meetups
    • Webinars
    • Resources
Careers Get in touch
  • About us
  • Services
    • Software Development
      • Frontend Development
      • Backend Development
    • Staff Augmentation
      • Frontend Developers
      • Backend Developers
      • Data Engineers
      • Cloud Engineers
      • QA Engineers
      • Other
    • It Advisory
      • Audit & Consulting
  • Value for
    • CEO
    • CTO
    • Delivery Manager
  • Our team
  • Case Studies
  • Know How
    • Blog
    • Meetups
    • Webinars
    • Resources
Careers Get in touch
Back arrow GO BACK
2018-09-09
Software Development

HOW TO DOCKER LESSON LEARNED

Dawid Polchlopek

Ever since I noticed that the application we prepared has expanded significantly, I have decided to find a completely new method for automation of the process of its launching. It was important for me to find a solution which would make it possible to activate new features in isolation.

Introduction

Discovering a simpler method of process automation would be a significant improvement of my work as well as the work of my entire team. I thought “Why not use Docker?”

During the preparation stage, I created two setups: one for the front-end application, and the other for API. Below you can see a presentation of what I’ve learned during the development process.

The first problem

I want to have a cloned repository in the container, so I added an ssh key via the ADD command in Dockerfile:

ADD ~/.ssh/testowy

And bam! The file is not found. Why?

Let’s assume that we have the following folder structure:

docker/
|-- stuff/
| |-- test.txt
|-- Dockerfile
server/
|-- data
| |-- setup.yml

Run command build in the login-queue folder and you can only add files from the local folder and its local subfolders, e.g. stuff.

If you want to add the server folder, you’ll receive a message: “unable to prepare context”

Dockerignore

Ever wondered why the image takes so long to build? Maybe you didn’t use .dockerignore, to ignore files which are not necessary in the image. The .git folder should be removed automatically as well as any temporary files.

Order of commands in Dockerfile

Docker saves each line form Dockerfile and after building each line is saved as a layer. It is very important not to change the order of particular commands too often.

FROM ubuntu
RUN apt-get install -y software-properties-common python
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://us.archive.ubuntu.com/ubuntu/ precise universe" >> /etc/apt/sources.list
RUN apt-get update
RUN apt-get install -y nodejs
RUN apt-get install -y nodejs=0.6.12~dfsg1-1ubuntu1
RUN mkdir /var/www

ADD app.js /var/www/app.js

CMD ["/usr/bin/node", "/var/www/app.js"]

For example, if you change the last line in Dockerfile, all previous lines will be downloaded from the cache while the last line will be modified. When you replace line No. 4, then all lines starting from Line 4 to the end, will be modified. For this reason it is worth to place commands which will not change, at the beginning of the file.

Copying files to image

It’s worth considering what a given image will be used for. If you need it to launch a service once, just copy the code content directly to the image:

COPY . /workdir

Unfortunately, this makes it impossible to edit files and every time you want to edit your code, you’ll have to build the image again.

If you’re using MacOS and want to use the built image for development, you have to approach this matter in a slightly different way. If you will use volumes then you have to be prepared that this is an extremely slow solution (e.g. copying a file from the host to the container is done with the speed of 4.5 MB/s, while copying internally in the container with speed 10-20x higher). Luckily, as you can see at link, the problem has been known and its solution is the key issue for the team responsible for developing Docker for Mac.

How can you use Docker for development in this situation?

You can use it for external services, e.g. Redis/PSQL/Elasticsearch or use ready solutions, which offer rsync: https://github.com/brikis98/docker-osx-dev

To sum up

If you have a big team and wish to test a new feature, docker will be the ideal tool! Nevertheless, would I use it for a production launch of a server? I’m not fully convinced yet…

Additionally, I recommend a few outstanding articles:

  • how to test images
  • something else about Docker, but also worth mentioning
  • last but not least, Docker documentation

Related articles

Software Development

Build Future-Proof Web Apps: Insights from The Codest’s Expert Team

Discover how The Codest excels in creating scalable, interactive web applications with cutting-edge technologies, delivering seamless user experiences across all platforms. Learn how our expertise drives digital transformation and business...

THECODEST
Software Development

Top 10 Latvia-Based Software Development Companies

Learn about Latvia's top software development companies and their innovative solutions in our latest article. Discover how these tech leaders can help elevate your business.

thecodest
Enterprise & Scaleups Solutions

Java Software Development Essentials: A Guide to Outsourcing Successfully

Explore this essential guide on successfully outsourcing Java software development to enhance efficiency, access expertise, and drive project success with The Codest.

thecodest
Software Development

The Ultimate Guide to Outsourcing in Poland

The surge in outsourcing in Poland is driven by economic, educational, and technological advancements, fostering IT growth and a business-friendly climate.

TheCodest
Enterprise & Scaleups Solutions

The Complete Guide to IT Audit Tools and Techniques

IT audits ensure secure, efficient, and compliant systems. Learn more about their importance by reading the full article.

The Codest
Jakub Jakubowicz CTO & Co-Founder

Subscribe to our knowledge base and stay up to date on the expertise from the IT sector.

    About us

    The Codest – International software development company with tech hubs in Poland.

    United Kingdom - Headquarters

    • Office 303B, 182-184 High Street North E6 2JA
      London, England

    Poland - Local Tech Hubs

    • Fabryczna Office Park, Aleja
      Pokoju 18, 31-564 Kraków
    • Brain Embassy, Konstruktorska
      11, 02-673 Warsaw, Poland

      The Codest

    • Home
    • About us
    • Services
    • Case Studies
    • Know How
    • Careers
    • Dictionary

      Services

    • It Advisory
    • Software Development
    • Backend Development
    • Frontend Development
    • Staff Augmentation
    • Backend Developers
    • Cloud Engineers
    • Data Engineers
    • Other
    • QA Engineers

      Resources

    • Facts and Myths about Cooperating with External Software Development Partner
    • From the USA to Europe: Why do American startups decide to relocate to Europe
    • Tech Offshore Development Hubs Comparison: Tech Offshore Europe (Poland), ASEAN (Philippines), Eurasia (Turkey)
    • What are the top CTOs and CIOs Challenges?
    • The Codest
    • The Codest
    • The Codest
    • Privacy policy
    • Website terms of use

    Copyright © 2025 by The Codest. All rights reserved.

    en_USEnglish
    de_DEGerman sv_SESwedish da_DKDanish nb_NONorwegian fiFinnish fr_FRFrench pl_PLPolish arArabic it_ITItalian jaJapanese ko_KRKorean es_ESSpanish nl_NLDutch etEstonian elGreek en_USEnglish