docker笔记

Docker basics

1.Learn about images and containers

docker run hello-world执行命令的组成:
这里写图片描述

An image is a filesystem and parameters to use at runtime. It doesn’t have state and never changes. A container is a running instance of an image. When you ran the command, Docker Engine:

1.checked to see if you had the hello-world software image 2.downloaded the image from the Docker Hub (more about the hub later)
3.loaded the image into the container and “ran” it

2.Find and run the whalesay image

People all over the world create Docker images. You can find these images by browsing the Docker Hub.这么方便?

3.Build your own image

Step 1: Write a Dockerfile

A Dockerfile is a recipe which describes the files, environment, and commands that make up an image.

Remember that if you are using macOS or Windows, you are still creating an image which runs on Linux.

Step 2: Build an image from your Dockerfile

Step 3: Learn about the build process

Step 4: Run your new docker-whale

4.Create a Docker Hub account and repository

5.Tag, push, and pull your image

更多关于docker的知识

Define and deploy your app

1.Sample app overview

之前我们用Dockerfile来build,run whalesay app.

For this tutorial, the images are pre-built, and we use a stack file instead of a Dockerfile to specify the images. When we deploy, each image will run as a service in a container (or in multiple containers, for those that have replicas defined to scale the app).一个docker-stack.yml参考例子:

version: "3"
services:

  redis:
    image: redis:alpine
    ports:
      - "6379"
    networks:
      - frontend
    deploy:
      replicas: 2
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure
  db:
    image: postgres:9.4
    volumes:
      - db-data:/var/lib/postgresql/data
    networks:
      - backend
    deploy:
      placement:
        constraints: [node.role == manager]
  vote:
    image: dockersamples/examplevotingapp_vote:before
    ports:
      - 5000:80
    networks:
      - frontend
    depends_on:
      - redis
    deploy:
      replicas: 2
      update_config:
        parallelism: 2
      restart_policy:
        condition: on-failure
  result:
    image: dockersamples/examplevotingapp_result:before
    ports:
      - 5001:80
    networks:
      - backend
    depends_on:
      - db
    deploy:
      replicas: 1
      update_config:
        parallelism: 2
        delay: 10s
      restart_policy:
        condition: on-failure

  worker:
    image: dockersamples/examplevotingapp_worker
    networks:
      - frontend
      - backend
    deploy:
      mode: replicated
      replicas: 1
      labels: [APP=VOTING]
      restart_policy:
        condition: on-failure
        delay: 10s
        max_attempts: 3
        window: 120s
      placement:
        constraints: [node.role == manager]

  visualizer:
    image: dockersamples/visualizer:stable
    ports:
      - "8080:8080"
    stop_grace_period: 1m30s
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"
    deploy:
      placement:
        constraints: [node.role == manager]

networks:
  frontend:
  backend:

volumes:
  db-data:

2.Set up Dockerized machines

3.Create a swarm

4.Deploy the application

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值