Git Product home page Git Product logo

docker's Introduction

docker

Docker Compose Sample

Volume

將實體目錄或檔案對應Container裡的目錄或檔案

目錄對應

services:
  jenkins:
    image: jenkins/jenkins:lts
...
    volumes:
      - ./jenkins_home:/var/jenkins_home

在Container裡設定volumes,讓container裡的/var/jenkins_home對應到實際環境下的./jenkins_home

檔案對應

services:
  redis:
    image: redis:5
    ...
    volumes:
      - ./redis.conf:/usr/local/etc/redis/redis.conf

讓實際的./redis.conf取代Container裡的/usr/local/etc/redis/redis.conf,利用這樣來修改設定檔,就不用大量地增加environment

Container共用

要讓多個Container共用目錄,就必需在最外層設定Volume

services:
  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:6.5.4
    ....
    volumes:
      - esdata:/usr/share/elasticsearch/data

volumes:
  esdata:
    driver: local

此時docker會在系統的Volume裡建立一個特別的instance,使得其他的Container也能讀取到這個Volume.

常用的相關指令如下

#看目前docker有哪些volume

$ docker volume ls
DRIVER              VOLUME NAME
local               elk_esdata
local               f2bae14120c2531d90d0d01fe59916ef8cf5f164fc84dcb4b33833ee00fab523
# 檢視Volume的詳細資料

$ docker volume inspect elk_esdata
[
    {
        "CreatedAt": "2019-01-20T03:32:27Z",
        "Driver": "local",
        "Labels": {
            "com.docker.compose.project": "elk",
            "com.docker.compose.version": "1.23.2",
            "com.docker.compose.volume": "esdata"
        },
        "Mountpoint": "/var/lib/docker/volumes/elk_esdata/_data",
        "Name": "elk_esdata",
        "Options": null,
        "Scope": "local"
    }
]

docker's People

Contributors

elliotchen avatar ecpolyforce avatar

Watchers

 avatar James Cloos avatar

Forkers

jinhipa

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.