Creating a Docker image
The guide describes how to create and build a Docker image from a Dockerfile.
To work with Docker images, install and configure Docker.
-
Create a file named Dockerfile on your device and add the below lines to it:
FROM ubuntu:latest CMD echo "Hi, I'm inside"
The described Docker image is based on Ubuntu and will execute one simple command.
-
Assemble the Docker image. For
<registry_ID>
, use theID
you got when creating the registry.docker build . \ -t cr.yandex/<registry_ID>/ubuntu:hello
The
-t
flag assigns to the Docker image a URL incr.yandex/<registry_ID>/<Docker_image_name>:<tag>
format. You can build Docker images without any tag. In this case, the Docker CLI will assign the default label:latest
.
Once these commands are completed, a Docker image will be created in your repository with the hello
tag as well as the full address of the repository, including:
- Container Registry service address
cr.yandex
. - Your registry ID
<registry_ID>
. - Name of your
ubuntu
repository.