Docker, DevOps, and Deployment

Ayush Jain
5 min readOct 8, 2022
DevOps

Introduction on Docker

One of the most sought-after technologies in the IT sector today is Docker, a containerization and DevOps platform. This potent program supports container-based application deployment. Docker provides a stable and dependable environment that streamlines the application lifecycle development process. You may streamline your processes with the help of Docker Compose, a more sophisticated tool in the Docker suite.

Docker is a free technology that uses the containerization idea to streamline the application development and deployment processes. With the help of containers, we can ship an app’s components as a single unit for deployment.

With this application, several developers may work in sync on the same project without worrying about OS incompatibilities or dependency difficulties. While virtual machines isolate apps, Docker allows them all to share the same Linux kernel.

Docker

Dockerfile

Using Dockerfiles, we can “containerize” our application by creating a new container from a previously constructed image and adding our logic to launch the container. Using the Dockerfile as a starting point, we generate an image with the help of the Docker build command.

Docker Compose

Docker Compose is used to create and manage applications that span several containers. Compose allows you to set up your application’s services in a YAML file and automatically generate those services for you.
It’s a multi-container process that runs automatically. Compose is a fantastic resource for setting up staging, development, and testing environments in addition to CI processes.

Deployment

Deployment is the process of taking your application to production which means hosting your site on a server for others to access it with the click of a link. There are various categories of hosting your application; some of them include Dedicated Web Server, VPS (DigitalOcean), Cloud(AWS), PaaS (Heroku), etc.

VPS

A VPS, also known as a virtual private server, is a virtual server that operates in isolation on a shared physical server. Virtual private servers (VPSs) are created by partitioning a single physical server into many independent virtual servers (VMs).

DigitalOcean

Hosting through DigitalOcean Droplets

The CapRover one-click app for DigitalOcean is the preferred way of installation. In the DigitalOcean store, you can get CapRover with only a single click. However, you do need two prerequisites- a domain name and a server. A wildcard DNS entry must be set up with your CapRover IP address during setup.

You can create a new droplet and add all your configuration s which include server, plan, CPU options, block storage, datacenter region, authentication option, etc. PRO TIP- Select the data center region nearest to you and use an SSH key instead of a password for more security.

Once you create your droplet, you can access your caprover dashboard by visiting your IP-ADDRESS:3000. From there you can set up your caprover CLI to easily deploy your application.

RECOMMENDED — When setting up your root domain name, always go one level deeper as once you add HTTPS you won't be able to change it. For example, if your domain name is ayushjain-10.me, use dev.ayushjain-10.me. This allows for better security and subdomain management.

Caprover

Caprover Deployment Methods

Caprover provided numerous ways to deploy your application like Official CLI, Tarball, Deployment from GitHub/Bitbucket/Gitlab, Plain Dockerfile, Captain Definition File, and ImageName.

You can try deploying some of its sample applications which can be found at - link. In addition to adding web apps, you can also choose a database or bundle (web app+database), some of which include MongoDB, PostgresSQL, Prisma, Redis, etc.

Uptime Monitoring - Alerts & Notifications

There are several ways your application can break down even after it has been deployed such as domain resolution errors, degraded performance, etc. It is not feasible to maintain all your applications by yourself and manually check whether each route and service in your application is up and running.

Freshping

FreshPing

In comes Freshping!! With fast notifications for downtime or slowdown, Freshping is a straightforward solution for keeping tabs on the availability and performance of your websites, APIs, online services, and web applications. It has an alarm, notification, and alert system that keeps you abreast of any potential developments on the websites at all times. Additionally, it has a very straightforward user interface, allowing you to locate sites in a matter of seconds and receive issues within the same time frame, allowing you to address them immediately.

It has a super fast and easy setup. Enter your domain. Add your application URLs. Done!

Status Page

Additionally, you can add a status page that will show you the availability, downtime, and performance of all your applications simultaneously, e.g. — link.

Alternatively, you can setup Netdata which collects metrics from all your servers and databases and sends it into a super fast and interactive visualizer for error detection. It sends you reports to your email on performance and other issues. It is used by big companies such as Amazon, Google, Groupon, Microsoft, DigitalOcean, etc.

You can set it up in Caprover by going to the monitoring section and cling on ‘Start Netdata Engine’.

My Experience

Using Docker and Docker Compose for the first time can be overwhelming due to all the command line options and configuration elements. The biggest lesson I learned while doing DevOps is always resisting the temptation to do anything you don't know, from adding new variables to running code in the command line because it is way faster and easier to break code than to fix it. Another important lesson is to always read the documentation before doing something for the first time. I would rather spend hours reading documentation than hours fixing my code.

Setting up my Caprover went by fairly quickly with the help of an incredible tutorial setup by my instructor. One of the problems I faced when deploying a Node/MongoDB application was an ERROR 502 NGINX error that was caused due to a port incompatibility — my app was running on a different port and the server was listening on a different port. To solve this I changed the Nginx default port in caprover HTTP setting and added a PORT env variable pointing to my port in the App Configs section.

--

--