Blog Details

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
05 Feb 2024

Embed Youtube video in mdx file.

How to Embed Youtube video in mdx file -by Evan Dangol

image
05 Feb 2024

Get Free Linux Virtual Machine Forever in Cloud.

Comparasion of free tier AWS, Azure and Google cloud virtual machines -by Evan Dangol

image
05 Feb 2024

.Net MAUI, Local Web Api Access From Mobile Phones During Development

How to Access local web api from mobile device -by Evan Dangol