Use exec when starting from scripts
Choices include supervisor, dumb-init, tini
Isolate in sidekicks
FROM ubuntu:xenial-20180123
RUN apt-get update \
&& apt-get -y install nginx
ENTRYPOINT [ "nginx", "-g", "daemon=off;" ]
FROM ubuntu:xenial-20180123
RUN apt update \
&& apt install -y nginx
ADD entrypoint.sh /
ENTRYPOINT /entrypoint.sh
#!/bin/bash
#...
exec nginx -g daemon=off;
FROM ubuntu:xenial-20180123
RUN apt update \
&& apt install -y \
nginx \
supervisor
ADD nginx.conf /etc/supervisor/conf.d/
ENTRYPOINT [ "supervisord" ]
nginx.conf
[program:nginx]
command=nginx -g daemon=off;
–
My own tests prove otherwise
–
dind -> dind-gocd-agent
linux-agent -> linux-agent-gocd
-> linux-agent-jenkins
-> linux-agent-gitlab
Base:
FROM ubuntu
RUN apt-get update \
&& apt-get -y install curl wget unzip jq
Derived:
FROM base
RUN touch /tmp/derived
–
Used for controlling version pinning
Used for tweaking runtime behaviour
E.g. Install distribution packages
Packages and scripts required for the purpose of the image
–
Obtain file hash from the web
Create file hash after manual download
Check file hash during image build
echo "${HASH} *${FILENAME}" | sha256sum --check
–
Bad idea™
Add USER statement after setting up image
Some services handle this for you (nginx)
FROM ubuntu
# install
USER go
Change to root
Install more tools
Change back to user
FROM derived
USER root
# install
USER go
–
Easily find corresponding code
Deprecated: https://label-schema.org
–
FROM ubuntu:xenial-20180123
LABEL \
org.opencontainers.image.created=“2018-01-31T20:00:00Z+01:00“ \
org.opencontainers.image.authors=“nicholas@dille.name“ \
org.opencontainers.image.source=“https://github.com/nicholasdille/docker“ \
org.opencontainers.image.revision=“566a5e0“ \
org.opencontainers.image.vendor=“Nicholas Dille“
–
Prevent usage of outdated images
docker build --pull ...
Synchronize time
docker run -v /etc/localtime:/etc/localtime ...
Build argument defines default base image
ARG VERSION=xenial-20180123
FROM ubuntu:${VERSION}