How I started with Dockers

Sreedhar Bukya
2 min readSep 26, 2018

This is a small story, How I started with dockers very quickly.

If this is the first you heard about Docker. Its highly recommended reading its wiki page.

Docker is software which allows you to run independently “containers” with single Linux instance, avoid the overhead of running VMs.

If you are an application developer. Have you ever come across these issues.

  • “It works on my system”. but not working on another system.
  • How difficult, It was for upgrading the underline OS?
  • What are the difficulties of automating your app?

I went through pain automation of deployment for my apps. It is more painful your developer machine OS different than deployment server OS.

Docker gives you the flexibility to build, Ship and Run anywhere. Once you containerize your app. It doesn’t matter where you deploy. It works the same.

Key Terms:

Docker: Software /Program that performs OS-level virtualization.

Container: A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings

How did I get started?

My case: I was trying to build the web app which has the following structure.

  • Python/Django as a backend app for RESTful APIs.
  • Angular app for User Interface.
  • Postgres as database
  • Nginx as a web server and proxy forward to the backend server and UI.

First, I started with Dockerfile.

What is the Dockerfile?:

It has instruction, How should we package software and pre-installation scripts to be added.

For an example: snippet for Python/Django app.

https://gist.github.com/a21858af5300cb2feb489e935bc91a48

Some more info about dockerfile

docker-compose.yml:

For a distributed app, There will be different services to launch. This file will have instructions

  • How to launch a service
  • How is dependent on other services.
  • Command to start.
  • Ports to expose

It was an example for my app:

https://gist.github.com/a55193982ea97b20ebda1c6f013dc5bb

Note:

It is important to understand networks in your docker-compose.yml. If you are deploying multiple services. It is important all your services are the same network. Learn more networking in dockers

Here is the GitHub source code which you can use for reference.

I hope it gave starter understanding of dockers.

Enjoy, shipping the containers.

Originally published at gist.github.com.

--

--