Docker intro

image

27 Jan 2024

09

35

Docker: Simplifying Application Deployment

Docker is a powerful platform that streamlines the process of developing, packaging, and deploying applications. It utilizes containerization technology to encapsulate applications and their dependencies into lightweight, portable containers. These containers ensure consistency across different environments, making it easier for developers to work seamlessly from local development to production deployment.

Key Advantages of Docker

1. Portability:

Docker containers can run consistently on any system, whether it's your local machine, a testing environment, or a production server. This eliminates the infamous "it works on my machine" problem.

2. Isolation:

Containers provide a level of isolation for applications, ensuring that they don't interfere with each other. This isolation enhances security and simplifies dependency management.

3. Efficiency:

Docker optimizes resource utilization by sharing the host operating system's kernel. This results in faster startup times and efficient use of system resources.

Getting Started with Docker

To get started with Docker, follow these basic steps:

  1. Install Docker: Head to the official Docker website and download the Docker Desktop application suitable for your operating system.

  2. Create a Dockerfile: Define your application's environment, dependencies, and runtime instructions in a Dockerfile. This file serves as a blueprint for building Docker images.

  3. For Example :

- for private repo

FROM ubuntu

RUN apt update && apt install -y apache2 curl nano unzip

ARG GITHUB_TOKEN
ENV GITHUB_TOKEN=${GITHUB_TOKEN}

RUN curl -LJO "https://codeload.github.com/edangolgithub/evanhtmlprivate/zip/refs/heads/master" -H "Authorization: token $GITHUB_TOKEN" \
    && unzip -q evanhtmlprivate-master.zip -d /var/www/html/ \
    && mv /var/www/html/evanhtmlprivate-master/* /var/www/html/


CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]

- for public repo

FROM ubuntu

RUN apt update && apt install -y apache2 curl nano unzip

ADD https://codeload.github.com/edangolgithub/evanhtml/zip/refs/heads/master /var/www/html/code.zip

RUN cd /var/www/html/ && unzip code.zip && mv /var/www/html/evanhtml-master/* /var/www/html/

CMD ["/usr/sbin/apachectl", "-D", "FOREGROUND"]

  1. To Build :
docker build --build-arg GITHUB_TOKEN=personal_access_token -t evanhtmlprivate -f private.dockerfile .

  1. To Run :
docker run -p8888:80 evanhtmlprivate

Join our newsletter!

Enter your email to receive our latest newsletter.

Don't worry, we don't spam

image

Related Articles

image
14 Feb 2024

Deploying a FREE Nodejs Serverless API in Vercel with Zenstack, Prisma and Neon's Free PostgreSQL

Explore the process of deploying a serverless API with Vercel, leveraging Zenstack for Prisma integration, TypeScript for enhanced development, and Neon's complimentary PostgreSQL database for your project. -by Evan Dangol

image
07 Feb 2024

Harnessing Machine Learning to Detect Toxic Comments - Using Calibrated Binary Classification Metrics Module

Unveiling Machine Learning's Power- Detecting Toxic Comments with C# -by Evan Dangol

image
06 Feb 2024

Will gRPC ultimately replace REST Api in future? A simple gRPC using nodejs with Nextjs

It's unlikely that gRPC will entirely replace REST (Representational State Transfer) API in the near future, as both technologies have their own strengths and are suitable for different use cases.gRPC (Google Remote Procedure Call) is a high-performance...