LoginSignup
722
622

More than 3 years have passed since last update.

至高のDockerイメージ生成を求めて

Last updated at Posted at 2016-12-21

稿Docker
Supership Advent Calendar 201621

2019@inductor
姿2019multi-stage build2016

Docker


DockerDocker


(一)





(二)

(三)

(四)





(五)APIDocker Hub

使







(一)volume

(二)privileged

(三)

(四)

(五)


(3)(4)稿

(1)
KubernetesConfigMapSecretsvolume(1)


COPYCredentialCOPY.dockerignore
悪いDockerfile
FROM ruby
COPY . /opt/myapp/
良いDockerfile
FROM ruby
COPY bin src config /opt/myapp/





悪いDockerfile
FROM ruby
WORKDIR /opt/myapp

COPY ./ /opt/myapp
RUN bundle install # Gemfileに変更がなくても実行される

bundle install再実行の図
docker buildID
.COPYRUN
ruby gems
良いDockerfile
FROM ruby
WORKDIR /opt/myapp

COPY Gemfile* /opt/myapp
RUN bundle install
COPY ./ /opt/myapp

GemfileGemfile.lockbundle installRUNGemfileGemfile.lock



悪いDockerfile
FROM golang
COPY ./ /go/src/github.com/foo/bar
RUN go get github.com/foo/bar

コンパイル問題の図


Go
RUN rm ...

DockerfileDockerfile
Makefile
all: docker-build

docker-build: bin/bar
    docker build -t gcr.io/my-project/foo .

bin/bar: *.go
    go build -o bin github.com/foo/bar

.PHONY: docker-build
Dockerfile
FROM busybox
COPY bin/bar /usr/local/bin/




Golang

CI -- C++JavacscalagorubypythonnoderustmakeautotoolsbisonopensslprotoclintCCI



docker






使
dockerdocker pull
Makefile
all: docker-build

docker-build: bin/bar
    docker build -t gcr.io/my-project/foo .

bin/bar: *.go
    docker run --rm \
     -v $PWD/bin:/go/bin \
     -v $PWD:/go/src/github.com/foo/bar \
     go get github.com/foo/bar

.PHONY: docker-build
Dockerfile
FROM busybox
COPY bin/bar /usr/local/bin/

golang使Dockerfile


Dockerfile

膨れ上がったコンテナ化ビルドステップの図




DockerfileDockerfiledocker buildCI
FROM golangCI

DockerfileDockerfileMakefile






docker multi stage build便

golang-builder



golang

Bazel


Dockerfiledocker build


BazelBazelDockerBUILD
BazelDocker
go getbundle installDockerbazel build1

Google Cloud Container Builder


volume

Google Cloud Container Builder

DockerYAMLpullvolume mountpush

c.f. Google Cloud Container Builder使




id:kenzy_n: 


Docker




id:hylom Linux


DockerAMI.box.deb.rpm
2(1) gitcontent-hash (2) Docker engine
immutableDocker.deb.rpm

Dockerfiledebrpm10deploy5
container-nativedebian/rules.spec

.debDockerBazeldocker_build.deb




id:mapk0y: ( Dockerfile )/COPY  ADD 


ADD

1Dockerfile

(Vagrantfile + Chef)DockerfileCI(.travis.yml)使DockerBazel
DockerfileBazel BUILD1

Chef/PuppetDockerfileBazelgolang-builderGoogle Cloud Container Builder
722
622
4

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
722
622