AppSec & Pentest
CloudSec
CloudSec
  • Sandboxes, Containers, Virtualization
    • Какие бывают
    • Kubernetes
      • About
      • Tools
        • kubectl
        • minikube
        • helm
        • tiller
        • Others
      • Components
      • Concepts
      • Security
      • Learning
      • Conferences & Events
    • Container Runtime Interface (CRI)
      • containerd
      • CRI-0
      • Podman
      • Colima
      • Docker
        • About
        • CLI
        • Dockerfile
        • docker compose
        • Registry
        • Testcontainers
        • [Def] Security
        • [Off] Security
    • Red Hat OpenShift Container Platform (OCP)
      • About
      • OCP Components
        • Platform services
        • Application services
        • Developer services
        • OpenShift Kubernetes Engine
      • Security
        • Container Security
        • Podman
        • Kubernetes Security
        • Securing Platform Services
        • Vulnerabilities
        • CIS
    • VMWare
      • Workspace ONE Access
      • Workspace One UEM SSRF (AirWatch)
      • vSphere
      • vCenter
      • Learn
      • Horizon Security Server
      • VMWare log4j
    • Tools
      • Build container image inside containers
      • Moby
      • Security
  • Cloud
    • Google Cloud Platform (GCP)
      • GCP Components
      • GCP CLI
      • Security
        • Get access to GCP via service-account [json]
        • PrivEsc
        • Papers
      • Courses & Certifications
    • Azure
      • Azure Start
      • Azure CLI
      • Компоненты и механизмы
        • Azure Storage BLOB
        • Подписанные URL (SAS)
      • Papers and Resources
      • Azure Security Center
      • Tools
    • AWS
      • AWS Intro
      • AWS Basics
      • AWS Components
        • Computing
        • Storage
        • Messaging
        • Serverless
        • Business Productivity
        • Network and Content Delivery
        • Mobile
        • Databases
      • AWS Testing
      • Basic Work: Examples
        • AWS Cli
        • AWS SES
        • S3 Bucket
      • Security
        • Enumeration
        • AWS Lambda
        • Разные примеры
        • Learn Materials
      • Books & Papers
      • Courses & Certifications
    • Yandex Cloud
      • YC CLI
      • YC API
      • Cloud Organization
      • VM
        • Cloud Computing
        • Virtual Private Cloud (VPC)
        • Network Load Balancer
      • Data Platform
        • Definitions
        • Как выбрать БД
        • Реляционные БД
        • Нереляционные БД
        • Object Storage and S3
      • Yandex k8s
      • Serverless
      • Security
      • Billing
    • Another platforms
    • OpenStack
    • Tools
      • Tool list
      • Packer
      • Terraform
        • Intro
        • Getting started
        • Configuration
          • Basic
            • Terraform Block
            • Providers
            • Resources
            • Variables
            • Outputs
            • Functions
          • Modules
        • Security
        • Papers
    • Papers
Powered by GitBook
On this page
  • Build image from Dockerfile
  • Цепочка FROM в Dockerfile
  • ENTRYPOINT & CMD
  • Статьи

Was this helpful?

  1. Sandboxes, Containers, Virtualization
  2. Container Runtime Interface (CRI)
  3. Docker

Dockerfile

Build image from Dockerfile

Собираем из локального файла:

docker build .
docker build -f MyDockerfile -t ikemurami/myimage:v1.0 /path/to/dir/context

Цепочка FROM в Dockerfile

В dockerfile допустимо делать цепочки из образов. То есть билдим один образ (golang AS builder) для билда, а для запуска используем другой (alpine) и перекидываем бинарь из первого командой COPY.

FROM golang:1.14-stretch AS builder

ENV CGO_ENABLED=0
ENV GOOS=linux
ENV GO111MODULE=on

RUN mkdir -p /go/src/example.com/test/project
ADD . /go/src/example.com/test/project

WORKDIR /go/src/example.com/test/project/

# RUN go test -mod vendor  -v ./...
RUN go build -mod vendor -a -o /bin/project /go/src/example.com/test/project/cmd/main.go



FROM alpine:3.10

RUN apk --no-cache add ca-certificates

WORKDIR /bin
COPY --from=builder /bin/project  /bin/project

EXPOSE 8080

ENTRYPOINT ["/bin/project"]

ENTRYPOINT & CMD

ENTRYPOINT определяет программу, которая будет запускать при старте контейнера (по умолчанию, /bin/sh -c).

CMD — определяет аргументы для ENTRYPOINT.

Соотв, если мы хотим сделать контейнер, посвященный одной программе, то переопределяем ENTRYPOINT.

Статьи

PreviousCLINextdocker compose

Last updated 2 years ago

Was this helpful?

По командам докера (Dockerfile):

https://habr.com/ru/company/ruvds/blog/439980/
https://infoboxcloud.ru/community/blog/infoboxcloud/200.html