Docker: build

docker build

Builds an image from a Dockerfile and a context. The context is the files at a path or URL.


docker build -t my/target-name .


  • the argument for -tis the repository

  • 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

Successfully built e35dd0eb8db1
Successfully tagged repo/name:latest

even if nothing has changed.

  • use -f to specify a Dockerfile

  • 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 instruction is a variable that can be passed in at build time. E.g.
–build-arg <varname>=<value>

Note: it’s the only command that can appear before a FROM command.



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>


Leave a Reply

Your email address will not be published. Required fields are marked *