FROM
Usage:
|
|
MAINTAINER
Usage:
MAINTAINER instruction allows you to set the Author field of the generated images.Reference |
|
RUN
Usage:
|
|
CMD
Usage:
|
|
LABEL
Usage:
|
|
EXPOSE
Usage:
|
|
ENV
Usage:
|
|
ADD
Usage:
|
|
COPY
Usage:
|
|
ENTRYPOINT
Usage:
|
|
VOLUME
Usage:
Reference - Best Practices |
|
USER
Usage:
USER instruction sets the user name or UID to use when running the image and for any RUN , CMD and ENTRYPOINT instructions that follow it in the Dockerfile.Reference - Best Practices |
|
WORKDIR
Usage:
|
- Sets the working directory for any
RUN
,CMD
,ENTRYPOINT
,COPY
, andADD
instructions that follow it. - It can be used multiple times in the one Dockerfile. If a relative
path is provided, it will be relative to the path of the previous
WORKDIR
instruction.
ARG
Usage:
ARG
[= ]
- Defines a variable that users can pass at build-time to the builder with the
docker build
command using the--build-arg
flag.= - Multiple variables may be defined by specifying
ARG
multiple times. - It is not recommended to use build-time variables for passing secrets like github keys, user credentials, etc. Build-time variable values are visible to any user of the image with the docker history command.
- Environment variables defined using the
ENV
instruction always override anARG
instruction of the same name. - Docker has a set of predefined
ARG
variables that you can use without a corresponding ARG instruction in the Dockerfile.HTTP_PROXY
andhttp_proxy
HTTPS_PROXY
andhttps_proxy
FTP_PROXY
andftp_proxy
NO_PROXY
andno_proxy
ONBUILD
Usage:
ONBUILD
- Adds to the image a trigger instruction to be executed at a later
time, when the image is used as the base for another build. The trigger
will be executed in the context of the downstream build, as if it had
been inserted immediately after the
FROM
instruction in the downstream Dockerfile. - Any build instruction can be registered as a trigger.
- Triggers are inherited by the "child" build only. In other words, they are not inherited by "grand-children" builds.
- The
ONBUILD
instruction may not triggerFROM
,MAINTAINER
, orONBUILD
instructions.
STOPSIGNAL
Usage:
Reference
STOPSIGNAL
STOPSIGNAL
instruction sets the system call signal
that will be sent to the container to exit. This signal can be a valid
unsigned number that matches a position in the kernel’s syscall table,
for instance 9
, or a signal name in the format SIGNAME, for instance SIGKILL
.Reference
HEALTHCHECK
Usage:
HEALTHCHECK [
(check container health by running a command inside the container)] CMD HEALTHCHECK NONE
(disable any healthcheck inherited from the base image)
- Tells Docker how to test a container to check that it is still working
- Whenever a health check passes, it becomes
healthy
. After a certain number of consecutive failures, it becomesunhealthy
. - The
that can appear are...--interval=
(default: 30s)--timeout=
(default: 30s)--retries=
(default: 3)
- The health check will first run
interval
seconds after the container is started, and then againinterval
seconds after each previous check completes. If a single run of the check takes longer thantimeout
seconds then the check is considered to have failed. It takesretries
consecutive failures of the health check for the container to be consideredunhealthy
. - There can only be one
HEALTHCHECK
instruction in a Dockerfile. If you list more than one then only the lastHEALTHCHECK
will take effect.
can be either a shell command or an exec JSON array.- The command's exit status indicates the health status of the container.
0
: success - the container is healthy and ready for use1
: unhealthy - the container is not working correctly2
: reserved - do not use this exit code
- The first 4096 bytes of stdout and stderr from the
are stored and can be queried withdocker inspect
. - When the health status of a container changes, a
health_status
event is generated with the new status.
SHELL
Usage:
SHELL ["
", " ", " "]
- Allows the default shell used for the shell form of commands to be overridden.
- Each
SHELL
instruction overrides all previousSHELL
instructions, and affects all subsequent instructions. - Allows an alternate shell be used such as
zsh
,csh
,tcsh
,powershell
, and others.