Skip to content
Menu
myCloud myCloud

Personal short notes about Cloud

  • XMPie
  • AWS
    • AWS Topics
    • AWS Architecture
    • AWS CLI
    • AWS Health
    • AWS Policies
    • AWS Cost
  • CHEAT SHEETS
myCloud myCloud

Personal short notes about Cloud

VM vs Docker container

By mikado on January 4, 2023January 7, 2023

VM

  • Each VM needs an OS, which uses significant resources

Docker container

In terms of virtualization:

  • Way to package application with all the necessary dependencies and configuration
  • Can be considered as layers of images:
    • alpine:3.10 – linux base image
    • postgres:10.10 – application image
    • ..
  • Portable artifact, easily shared and moved around

  • Containers start up very quickly
  • Containers resource efficient
  • Each container is isolated from other containers
  • A container has all needed for running the application:
    • code
    • settings
    • dependencies

Development & deployment more efficient

DockerHub

  • Public repository
  • hub.docker.com

Docker file

  • Instructions for building a Docker image.

This dockerfile installs Apache webserver and sets the default command to run the Apache daemon:

FROM ubuntu:20.04

RUN apt-get update && apt-get install -y apache2

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

  • Build the Docker image:
docker build -t my-image .
  • Run the Docker image:
docker run -p 8080:80 my-image

Docker-compose

  • Define and run multi-container Docker applications.
  • Uses configuration file (docker-compose.yml) to specify the different containers and their configurations, and then creates and runs them with a single command.
version: '3'
services:
  web:
    image: nginx:latest
    ports:
      - "80:80"
  database:
    image: postgres:latest
    environment:
      - POSTGRES_PASSWORD=mypassword
    volumes:
      - db-data:/var/lib/postgresql/data
volumes:
  db-data:
  • two containers: “web” and “database“
    • web container: NGINX, exposes port 80 to the host
    • database container: PostgreSQL, sets the POSTGRES_PASSWORD environment variable. It also mounts a volume named “db-data” at the specified location in the container.

Run docker compose application

docker-compose up
Category: Container

Categories

  • AWS (4)
  • AWS Architecture (8)
  • AWS CLI (5)
  • AWS Cost (3)
  • AWS Health (4)
  • AWS Policies (2)
  • AWS Topics (24)
  • CHEAT SHEETS (16)
  • Container (21)
  • Datadog (4)
  • Jenkins (2)
  • Linux (9)
  • Microsoft (7)
  • Python (1)
  • SCRIPTS (9)
  • Terraform (5)
  • XMPie (6)
©2025 myCloud
Click to Copy