Forrest logo
back to the docker tool

docker:tldr:e4e78

docker: Build a docker image and tag it.
$ docker build --tag ${name:tag} .
try on your machine

This command is used to build a new Docker image, with a specified tag, from a Dockerfile located in the current directory.

Here's a breakdown of the command:

  • docker build: This is the Docker command used to build a new Docker image.
  • --tag ${name:tag}: This is an option to specify the name and tag for the new image. The value for this option is given by ${name:tag}. The ${name:tag} syntax is typically used to reference environment variables that provide the name and tag dynamically. For example, if the environment variable name is set to myapp and tag is set to latest, ${name:tag} resolves to myapp:latest. Alternatively, you can directly specify the name and the tag without using variables, such as --tag myapp:latest.
  • .: This specifies the build context, which is the directory containing the Dockerfile and any files that are referenced in the Dockerfile during the build process. In this case, . represents the current directory.

Overall, this command instructs Docker to build a new image with a specified name and tag using the Dockerfile located in the current directory.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the docker tool