2017-09-23 71 views
1

雖然泊塢窗機環境中建設新的碼頭工人圖像我注意到,10-12分鐘docker-compose build app命令凍結它開始實際構建過程之前:如何讓Docker Compose構建速度更快?

$ docker-compose build app 
Building app 

... 10 minutes ... 

Step 1/10 : FROM ruby:2.4.1 
---> e7ca4a0b5b6d 
... 

我試圖用--verbose參數,使其更具描述性的,但實際上並沒有幫助:

$ docker-compose --verbose build 
compose.config.config.find: Using configuration files: ./docker-compose.yml 
docker.auth.find_config_file: Trying paths: ['/Users/vtambourine/.docker/config.json', '/Users/vtambourine/.dockercfg'] 
docker.auth.find_config_file: Found file at path: /Users/vtambourine/.docker/config.json 
docker.auth.load_config: Couldn't find 'auths' or 'HttpHeaders' sections 
docker.auth.parse_auth: Auth data for {0} is absent. Client might be using a credentials store instead. 
compose.cli.command.get_client: docker-compose version 1.14.0, build c7bdf9e 
docker-py version: 2.3.0 
CPython version: 2.7.12 
OpenSSL version: OpenSSL 1.0.2j 26 Sep 2016 
compose.cli.command.get_client: Docker base_url: https://146.185.007.007:2376 
compose.cli.command.get_client: Docker version: KernelVersion=4.9.0-3-amd64, Arch=amd64, BuildTime=2017-09-05T19:58:57.182575033+00:00, ApiVersion=1.30, Version=17.06.2-ce, MinAPIVersion=1.12, GitCommit=cec0b72, Os=linux, GoVersion=go1.8.3 
compose.project.build: db uses an image, skipping 
compose.service.build: Building app 
compose.cli.verbose_proxy.proxy_callable: docker build <- (pull=False, cache_from=None, stream=True, nocache=False, labels=None, tag='aerostat:app', buildargs={}, forcerm=False, rm=True, path='/Users/vtambourine/Code/aerostat', dockerfile='containers/development/Dockerfile') 
docker.api.build._set_auth_headers: Looking for auth config 
docker.api.build._set_auth_headers: Sending auth config (u'auths') 
compose.cli.verbose_proxy.proxy_callable: docker build -> <generator object _stream_helper at 0x10b61f230> 

... 10 minutes ... 

Step 1/10 : FROM ruby:2.4.1 
---> e7ca4a0b5b6d 

有什麼方法可以理解,發生了什麼以及如何使構建過程更快?

+0

當它在等待時,嘗試按下CTRL + C並查看是否收到異常跟蹤? –

+0

@TarunLalwani不,我什麼也沒有,只是沉默的停下來。 – vtambourine

+0

撰寫文件夾中'du -sh .'的輸出是什麼? –

回答

1

非常感謝Tarun Lalwani我瞭解了Docker的上下文。

構建上下文是位於指定位置的一組文件。我的(最微不足道的)案例位置僅僅是. - 項目目錄。構建過程的第一件事是將整個上下文複製到守護進程。由於我使用Docker Machine來部署我的容器Docker守護進程位於遠程主機上,這導致整個項目文件夾通過Internet發送到服務器。

與所有不必要的生產文件夾,如.gittmp,總規模爲這樣幾乎200 MB:

$ docker build -t my-app -f containers/production/Dockerfile . 
Sending build context to Docker daemon 187.9MB 

通過使用簡單的.dockerignore規則我能顯着減少碳排放量

$ docker build -t my-app -f containers/production/Dockerfile . 
Sending build context to Docker daemon 151kB 

吸取的教訓 - 使用.dockerignore

詳細解釋請見Dockerfile reference

相關問題