• Stars
    star
    331
  • Rank 127,323 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 9 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Show where time is wasted during the context upload of `docker build`

docker-show-context

Ever wonder why docker pauses when you do docker build, and what you can do about it? You know, when it says Sending build context to Docker daemon?

This program shows where time and bytes are spent when building a docker context.

It is based directly on the same logic that Docker itself uses to build the context.

Getting started (docker):

docker build -t docker-show-context https://github.com/pwaller/docker-show-context.git
docker run --rm -v $PWD:/data docker-show-context

Getting started (binaries):

Binaries are available on the releases page. Just grab the binary and put it in your path, then invoke it as docker-show-context. Use at your own risk.

Getting started (building from source):

You will need go 1.11 or more recent, which can be obtained from the go website.

Then run:

git clone https://github.com/pwaller/docker-show-context
cd docker-show-context
GO111MODULE=on go install -v

What the output looks like

The output looks something like this. It's easy to see now that I accidentally included some large binary content (*.deb and *.pdf files in particular), so I can now go and add those to my .dockerignore or delete them.

$ cd ~/path/to/project/using/docker
$ docker-show-context
Scanning local directory (in tar / on disk):
  24 / 1057 (62 / 216 MiB) (0.0s elapsed) .. completed

Excluded by .dockerignore: 1033 files totalling 153.98 MiB

Final .tar:
  24 files totalling 61.83 MiB (+ 0.02 MiB tar overhead)
  Took 0.04 seconds to build

Top 10 directories by time spent:
   40 ms: .
    1 ms: example

Top 10 directories by storage:
  61.83 MiB: .
   0.00 MiB: example

Top 10 directories by file count:
   23: .
    1: example

Top 10 file extensions by storage:
  57.10 MiB:
   4.71 MiB: .exe
   0.01 MiB: .pprof
   0.01 MiB: .md
   0.01 MiB: .go
   0.00 MiB: .sum
   0.00 MiB: .mod
   0.00 MiB: .sh
   0.00 MiB: .gitignore
   0.00 MiB: .dockerignore

Notes about the current behaviour

This documents the current behaviour, which may not be ideal, but it is what it is for now. Pull requests welcome.

  • The amounts shown don't show recursive usage, they just show a single level of the directory. (Otherwise, the root would always be the biggest thing).

  • Time records the amount of time between tarFile.Next() calls. I assume that this approximates the amount of time docker/pkg/archive spent constructing one tar entry. It might not be precise.

  • "Total content" shows the uncompressed bytes inside files inside the tar. The total amount sent to the docker daemon is this amount plus the tar overhead.

  • At this moment, only running with the build context root as the current working directory is supported, with a dockerfile named Dockerfile. Pull requests welcome to add parameters, so long as the existing default behaviour is preserved.

How can I use this to make building faster?

Frequently, I find that docker build suddenly takes longer than I expect. It is often the case that I have accidentally included some binaries or something which I did not intend to include. This the purpose of this tool is to give visibility into this, taking into account your existing .dockerignore, so that you can improve your .dockerfile or delete assets you don't need.

It scratches an itch.

License

The MIT License (MIT)

Copyright (c) 2016-2018 Peter Waller [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

pyfiglet

An implementation of figlet written in Python
Python
1,348
star
2

goupx

Fix golang compiled binaries on x86_64 so that they can be packed with UPX
Go
334
star
3

go2ll-talk

Live coding a basic Go compiler with LLVM in 20 minutes
Go
266
star
4

pyprof2calltree

Profile python programs and view them with kcachegrind
Python
156
star
5

goimports-update-ignore

Generate .goimportsignore and make goimports fast
Go
65
star
6

go-ffmpeg-video-encoding

Basic bindings for ffmpeg video encoding
Go
22
star
7

perf

Linux Perf subsystem bindings for Go
Go
21
star
8

go2ll

Extremely experimental toy go compiler
Go
19
star
9

waitsilence

an executable which blocks until it receives nothing on stdin for a specified time
Go
18
star
10

zerocopy

go zerocopy.Reader interface and implementation
Go
13
star
11

sharedextents

Show proportion of physical extents shared between two files
Go
12
star
12

fienode

Discover identical CoW copies, analogous to an inode
Go
11
star
13

go-clz4

fast cgo implementation of lz4
C
10
star
14

cartographer

Quickly find non-determinism bugs caused by loops over maps
Go
9
star
15

sha1-visualizer

Visualize SHA1 bit differences
JavaScript
7
star
16

usv

Go
7
star
17

iptables-block-dns

Block distractions by dropping DNS packets
Shell
5
star
18

git-minecraft-smudge

(defunct) Abusing git's filter mechanism for fun and profit.
Go
4
star
19

httpcache

{non,}Transparent MITM http{,s} proxy
Go
4
star
20

binview

A fun pointless visualization of arbitrary binary files
Python
3
star
21

pp2g

Crude python to go translator
Python
3
star
22

__autoversion__

Python
3
star
23

git-alot

Track the status of many git repositories
Python
3
star
24

go-hexcolor

golang Hex string color model
Go
2
star
25

jump

Jump to AWS machines
Go
2
star
26

gooda

C
2
star
27

minty

Python
2
star
28

wscat

cat. For websockets.
Go
2
star
29

bumphunter.pw

Simple implementation of the BumpHunter algorithm
Python
1
star
30

static-fusermount

Makefile
1
star
31

pwa

Python
1
star
32

inf

Infinity
Python
1
star
33

barrier

Signalling primitive for golang
Go
1
star
34

go-memhelper

Helper functions for avoiding OOM with many goroutines doing memory-heavy things
Go
1
star
35

ptrace-read

Go
1
star
36

httpservecache

Golang HTTP server caching middleware using groupcache
Go
1
star
37

fastwalk

Go
1
star
38

https-redirect

Redirect traffic from port 80 to 443
Go
1
star
39

keyboard

Keyboard offers a universal keyboard shortcut binding interface for various backends.
Go
1
star
40

runlocal

communicate commands to be run from remote to local over x-forwarding
Go
1
star
41

go-ping

Go
1
star