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

Docker 101

Docker 101

1. What is Docker and why Docker?
2. Docker engine and Docker architecture
3. Common Docker usage scenarios

Chih-Yu Yeh

December 05, 2019
Tweet

More Decks by Chih-Yu Yeh

Other Decks in Programming

Transcript

  1. Outline What is Docker and why Docker? Docker engine and

    Docker architecture Common Docker usage scenarios Use Docker images Create Docker images Publish Docker images 2
  2. Imagine the following scenarios which you might have experienced... 1.

    You have several projects at your local machine where each project's dependencies contradict with each other. ex: project A requires python3.6, but project B requires python3.7 2. You need to have multiple machines set up the same working environment. 3. You want to try some new features, but that requires lots of dependencies to be installed. 3
  3. What is Docker? Docker is an open platform for developing,

    shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly. With Docker, you can manage your infrastructure in the same ways you manage your applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, you can significantly reduce the delay between writing code and running it in production. (from Docker documentation) “ “ 4
  4. Simply put... 1. You write down everything required to run

    your application in a document. 2. Docker makes a box that packs your application according to your document, then you can move this box to everywhere you like. 3. Whenever you need to run your application, you only need to open the box again. Docker is a platform that enables you to accomplish above functionalities easily. 5
  5. Glossary 1. You write down everything required to run your

    application in a document(Dockerfile). 2. Docker makes a box(image) that packs your application according to your document, then you can move this box to everywhere(image registry) you like. 3. Whenever you need to run your application, you only need to open the box again.(container) 6
  6. Why Docker 1. Docker enables you to run your applications

    in isolated environments. -> No dependencies conflict anymore 2. You can make sure application environments are the same. (Collaboration is easier too) 3. Container is easily-disposable, you can test your applications quickly without polluting your environment. 7
  7. Common Docker usage scenarios 1. Use Docker images 2. Create

    Docker images 3. Publish Docker images 10
  8. Use Docker images docker run hello-world docker ps docker ps

    -a docker logs <container-id> docker inspect <container-id> docker stop <container-id> docker rm <container-id> docker <command> --help docker run -d -p 8086:80 nextcloud docker run -d -v /your/dir:/data/db mongo 11
  9. Create Docker images FROM node:11-alpine ENV diameter=4.0 COPY compute.js .

    CMD node compute.js docker build -t <image-name> . docker run --rm <image-name> docker run --rm -e diameter=5.0 <image-name> 12
  10. Publish Docker images docker tag <image-name> <dockerhub-id>/<image-name> docker login -u

    <dockerhub-id> -p <your-password> docker push <dockerhub-id>/<image-name> docker run <dockerhub-id>/<image-name> docker pull <dockerhub-id>/<image-name> 13
  11. Restart mode docker run -d -p 80 --restart unless-stopped nginx

    Monitoring docker stats Reclaim your disk docker container prune -f docker volume prune -f docker image prune -f Orchestration(managing running containers) Kubernetes or Docker Swarm are tools to help you manage containers 14