docker build
Builds an image from a Dockerfile and a context. The context is the files at a path
or URL
.
https://docs.docker.com/engine/reference/commandline/build/
E.g.
docker build -t my/target-name .
Notes
- the argument for
-t
is the repository
https://stackoverflow.com/questions/37815524/docker-build-tag-repository-name
https://docs.docker.com/engine/reference/commandline/tag/
- if you haven’t changed anything then Docker will simply take the last build you did and use that. So, don’t be fooled if the CREATED time is several weeks ago.
i.e. it will output stuff like
1 2 |
Successfully built e35dd0eb8db1 Successfully tagged repo/name:latest |
even if nothing has changed.
- use
-f
to specify a Dockerfile
https://stackoverflow.com/questions/27409761/multiple-dockerfiles-in-project
- the argument for
-t
must be lowercase otherwise you’ll get:
invalid reference format: repository name must be lowercase
and run it with:
docker run -it w/entrypoint_test sh
Dockerfile: passing in build-time arguments
ARG
ARG instruction is a variable that can be passed in at build time. E.g.
–build-arg <varname>=<value>
https://docs.docker.com/engine/reference/builder/#arg
Note: it’s the only command that can appear before a FROM
command.
https://docs.docker.com/engine/reference/builder/#understand-how-arg-and-from-interact
Problems:
Error response from daemon: Dockerfile parse error line 2: ADD requires at least two arguments, but only one was provided. Destination could not be determined.
ADD has format: ADD <local path> <destination path>