Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Introduction to Docker

Ananda Dwi Ae
September 15, 2020

Introduction to Docker

Ananda Dwi Ae

September 15, 2020
Tweet

More Decks by Ananda Dwi Ae

Other Decks in Technology

Transcript

  1. Perkenalan • Ananda Dwi Rahmawati • Cloud Eng, PT Boer

    Technology • Mahasiswa • Woman, Learner, FLOSS Enthusiast • https://t.me/misskecupbung
  2. Contents • Who knows about Docker? • Who uses Docker

    for development? • Who uses Docker in production? • Who tried but could not do it?
  3. Apa itu Docker? • Docker is an open platform for

    developing, shipping, and running applications. • Docker allows you to package an application with all of its dependencies into a standardized unit for software development.
  4. Sejarah Docker • Solomon Hykes (@solomonstre) • dotCloud (now Docker

    Inc) • March 2013 • Apache 2.0 license • 30k stars on Github • 260k public repositories on hub.docker.com • Docker Inc acquires everyone • Docker joins the "Open Container Initiative", June 2015
  5. Docker Benefits • Fast (deployment, migration, restarts) • Secure •

    Lightweight (save disk & CPU) • Open Source • Portable software • Microservices and integrations (APIs) • Simplify DevOps • Version control capabilities
  6. Common Docker Usages • Sandbox environment (develop, test, debug, educate)

    • Continuous Integration & Deployment • Scaling apps • Development collaboration • Infrastructure configuration • Local development • Multi-tier applications • PaaS, SaaS
  7. Technology Behind Docker • Linux x86-64 • Go language •

    Client - Server (deamon) architecture • Union file systems (UnionFS: AUFS, btrfs, vfs etc) • Namespaces (pid, net, ipc, mnt, uts) • Control Groups (cgroups) • Container format (libcontainer)
  8. Docker Component(s) Docker Machines • A tool which makes it

    really easy to create Docker hosts on your computer, on cloud providers and inside your own data center. It creates servers, installs Docker on them, then configures the Docker client to talk to them. Required for Mac, Windows users.
  9. Docker Component(s) Docker Compose • A tool for defining and

    running complex applications with Docker (eg a multi-container application) with a single file.
  10. Docker Component(s) Docker Swarms • A native clustering tool for

    Docker. Swarm pools together several Docker hosts and exposes them as a single virtual Docker host. It scale up to multiple hosts.
  11. Install Docker • Ubuntu : ◦ https://paste.ubuntu.com/p/XPkHJvvhK5/ • Debian :

    ◦ https://paste.ubuntu.com/p/7jM5JbMpCr/ • Run First Container : ◦ docker run hello-world
  12. Lab I - List version docker version docker info -

    Search images docker search <keywords> | https://hub.docker.com/ - Pull images docker pull image:tag docker images
  13. Lab II docker images docker run -it --name=<name> image:tag /bin/bash

    docker run -itd --name=<name> image:tag docker ps docker attach <ID_container> docker ps -a
  14. Lab III docker stop <id_container> docker start <id_container> docker logs

    <id>container> Docker events docker rm <id_container> Docker rm -f <id_container> Docker inspect <container>
  15. Lab IV docker pull ubuntu:18.04 docker run -it --name=httpd ubuntu:18.04

    /bin/bash apt update && apt install apache2 docker ps -a docker attach <id_container> docker commit <id_container> image
  16. Lab V docker save --output=name.tar image:tag docker import image.tar image:tag

    docker export id_container > container.tar docker load -i <image>.tar
  17. Lab VI mkdir first_image && cd first_image/ nano Dockerfile ...

    From ubuntu:18.04 Maintainer Ananda RUN apt update && apt install apache2 -y ... docker build . docker build -t first_image . docker images docker run --name=mycontainer first_image
  18. Lab VII - Docker Registry docker run -d -p 5000:5000

    --restart=always --name registry registry:2 echo "ip_vm hostname" >> /etc/hosts echo '{ "insecure-registries":["hostname:5000"] }' >> /etc/docker/daemon.json sudo systemctl enable docker && sudo systemctl restart docker sudo docker pull alpine:latest sudo docker tag alpine:latest hostname:5000/alpine:latest sudo docker push hostname:5000/alpine:latest
  19. Lab VIII - Docker Network docker network --help docker network

    create network-a docker run -itd ubuntu --network=network-a
  20. Lab IX - Docker Volume docker volume --help mkdir web

    echo “Hello World” >> web/index.html docker run -itd --name=web2 -p80:80 -v /home/ubuntu/web:/var/www/html web2