1
0
mirror of https://github.com/onkelbeh/cheatsheets.git synced 2025-06-16 07:07:37 +02:00
cheatsheets/dockerfile.md
OmegaSquad82 5b68e050e0
Add usage of strict shell (#1841)
Co-authored-by: Rico Sta. Cruz <rstacruz@users.noreply.github.com>
2022-06-09 12:11:24 +10:00

1.7 KiB

title category layout prism_languages updated
Dockerfile Devops 2017/sheet
docker
2019-10-20

Reference

{: .-three-column}

Inheritance

FROM ruby:2.2.2

Variables

ENV APP_HOME /myapp
RUN mkdir $APP_HOME
ARG APP_HOME=""
RUN mkdir $APP_HOME

Initialization

RUN bundle install
WORKDIR /myapp
VOLUME ["/data"]
# Specification for mount point
ADD file.xyz /file.xyz
COPY --chown=user:group host_file.xyz /path/container_file.xyz

Run commands in strict shell

ENV my_var
SHELL ["/bin/bash", "-euo", "pipefail", "-c"]

# With strict mode:
RUN false # fails build like using &&
RUN echo "$myvar" # will throw error due to typo
RUN true | false # will bail out of pipe

Using shell will turn on strict mode for shell commands.

Onbuild

ONBUILD RUN bundle install
# when used with another file

Commands

EXPOSE 5900
CMD    ["bundle", "exec", "rails", "server"]

Entrypoint

ENTRYPOINT ["executable", "param1", "param2"]
ENTRYPOINT command param1 param2

Configures a container that will run as an executable.

ENTRYPOINT exec top -b

This will use shell processing to substitute shell variables, and will ignore any CMD or docker run command line arguments.

Metadata

LABEL version="1.0"
LABEL "com.example.vendor"="ACME Incorporated"
LABEL com.example.label-with-value="foo"
LABEL description="This text illustrates \
that label-values can span multiple lines."

See also

{: .-one-column}