Docker

R3zk0n ยท October 2, 2025

Contents

    Introduction

    Source: https://www.youtube.com/watch?v=3c-iBn73dDE

    Public Repository of Containers

    • https://hub.docker.com/

    What problem does Docker address?

    Application Development

    • Before Docker, application development is difficult because of the need to install different services (Postgres, Redis) on different systems which could be convoluted and go wrong.
    • Docker has all the packages and dependencies already installed, and provides an isolated environment.
    • A single command can be used to install the application.
    • Can also run an application or multiple applications of different versions.

    Application Deployment

    • Develops provide artifacts with instructions on how to install and the operations team is in charge of installation.
    • This requires configuring the server, and also might have dependency and version issues.
    • With Docker, developers and operations team would work together and package the application into a container.
      • This Dockerfile would contain the necessary configurations, artifacts and dependencies.
      • No environmental configuration is needed on server - except Docker Runtime

    What is a container?

    • Layers of images
    • Mostly Linux Base Image (generally Alpine to keep the size small)
    • Begins with Linux base image, and then layers of images until application image (ex. postgres)
    • When pulling files the layers are individually downloaded
      # Retrieves the postgres official image from Dockerhub
      docker pull postgres
      
      # Fetches the postgres official image with version and executes the image
      docker run postgres:9.6
      
      # List Containers
      docker ps
    

    Difference between image and container

    • Images are the actual package โ€“> Artifact that can be moved around
    • The container environment that starts the application (on local machine)
    • Container is a running environment for image
    • Container has file systems, environment configs and application image (Virtual file system)

    Docker at an Operating System level

    Docker Virtualization

    • Applications (The part that Docker virtulizes)
    • OS Kernel (Linux Distribution)
    • Hardware

    VM

    • Applications + OS Kernel (Virtualization)
    • Hardware

    • This means that Docker images are much smaller, Docker containers can also be installed very fast
    • VM of any OS can run on any OS host โ€“> Linux on a Windows Host
    • This can be solved by using a Docker Toolbox to abstract the Kernel level and run images of any OS
    • Multiple containers run on the host machine, but two containers cannot share the same host port binding

    =========================================================================

    Installation

    • https://docs.docker.com/desktop/windows/install/
    • Also install Windows Subsystem for Linux (WSL 2)

    =========================================================================

    Docker Basic Commands

    Show all local image respository

    • docker images

    Pull the image to local repository

    • docker pull [image]

    Run image to create container in attached mode

    • docker run [image]

    Run image to create container in detached mode

    • docker run -d [image]
    • Version: docker run -d [image:version]
    • Port Binding: docker run -p [local]:[remote] [image]
      • Run the image first to check ports that need to be binded
    • Naming: docker run --name [NAME] [image]

    List running containers

    • docker ps

    Start and Stop running container

    • docker start [CONTAINER_ID]
    • docker stop [CONTAINER_ID]

    List running and stopped containers

    • docker ps -a

    Retrieve logs of container

    • docker logs [CONTAINER_ID]

    Execute command in container

    • docker exec -it [CONTAINER_ID] [COMMAND]

    =========================================================================

    Docker Workflow

    Simple Workflow with Docker

    • Develop an application, using Docker Hub to pull necessary services
    • The code gets commited to Git (version control)
    • The code then gets passed to Continuous Integration (CI, Jenkins build)
    • Artifacts are created and application is built into a Docker image (Jenkins build)
    • Pushed to a private Docker repository
    • Docker image is then deployed onto a development server (by pulling from private repository)
    • The dependencies on the development server are retrieved from Docker Hub

    Twitter, Facebook