Container Images, Find Them, Build Them

skang6283·2021년 1월 23일
0

Docker

목록 보기
4/6

이 포스트는 udemy: Docker Mastery: with Kubernetes +Swarm from a Docker Captain를 배우며 쓰는 글입니다


What's In An Image

  • App binaries and dependencies
  • Metadata about the iamge data and how to run the image

    Official Definition
    An image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime


Image and Their Layers

  • Images are made up of file system changes and metadaa
  • Each layer is uniquely identified and only stored once on a host
  • This saves storage space on host and transfer time on push/pull
  • A container is just a single r/w layer on top of image

Building Images

Dockerfile

**Package Manager** PM's like apt and yum are one of the reasons to build containers FROM Debian, Ubuntu, Fedora or CentOS

**Environment Variable** One reason they were chosen as preferred way to inject key/value is they work everywhere, on every OS and config

Example1 Velog가 DockerFile 코드블럭은 따로 서포트를 안하니 스크린샷으로...

Upon building an image based on a dockerfile,
Docker will go through each line adding layers and caching them so that if we try to use the same layer, it won't repeat it! 🪄

Example2

이 dockerfile은 기존에 있던 nginx에서 html을 바꿔주며 build 과정을 실행합니다. 결과적으로,


에서 아래 텍스트로 성공적으로 바뀐걸 볼수 있습니다.


Commands

docker pull get the lastest version of the iamge
but it is always better to specify the version.

**docker image +**
history show layeres of changes made in image
inspect return JSON metadata about the image
tag assign one or more tags to an image.
push push repo
build <image> . build an image from dockerfile from (dot) current directory.

prune clean up just "dangling" images, -a remove all images not being used.

-f specify dockerfile to build

--latest This tag is not actually latest, but it's just the default.(Docker standard)

Format: <user>/<repo>:<tag>


List of Docker Official Images can be found in https://github.com/docker-library/official-images/tree/master/library

profile
Hi :) I'm Max

0개의 댓글