Home Explore Blog CI



docker

2nd chunk of `content/get-started/introduction/build-and-push-first-image.md`
a6e4ffac173e382b6cacc37dc609f86f1254ba8c76c2b2d70000000100000d2d
Once you're done, you should see the **Sign in** button turn into a profile picture.

## Create an image repository

Now that you have an account, you can create an image repository. Just as a Git repository holds source code, an image repository stores container images.

1. Go to [Docker Hub](https://hub.docker.com).

2. Select **Create repository**.

3. On the **Create repository** page, enter the following information:

    - **Repository name** - `getting-started-todo-app`
    - **Short description** - feel free to enter a description if you'd like
    - **Visibility** - select **Public** to allow others to pull your customized to-do app

4. Select **Create** to create the repository.


## Build and push the image

Now that you have a repository, you are ready to build and push your image. An important note is that the image you are building extends the Node image, meaning you don't need to install or configure Node, yarn, etc. You can simply focus on what makes your application unique.

> **What is an image/Dockerfile?**
>
> Without going too deep yet, think of a container image as a single package that contains
> everything needed to run a process. In this case, it will contain a Node environment,
> the backend code, and the compiled React code. 
>
> Any machine that runs a container using the image, will then be able to run the application as 
> it was built without needing anything else pre-installed on the machine. 
>
> A `Dockerfile` is a text-based script that provides the instruction set on how to build
> the image. For this quick start, the repository already contains the Dockerfile.


{{< tabs group="cli-or-vs-code" persist=true >}}
{{< tab name="CLI" >}}

1. To get started, either clone or [download the project as a ZIP file](https://github.com/docker/getting-started-todo-app/archive/refs/heads/main.zip) to your local machine.

   ```console
   $ git clone https://github.com/docker/getting-started-todo-app
   ```

   And after the project is cloned, navigate into the new directory created by the clone:

   ```console
   $ cd getting-started-todo-app
   ```

2. Build the project by running the following command, swapping out `DOCKER_USERNAME` with your username.

    ```console
    $ docker build -t <DOCKER_USERNAME>/getting-started-todo-app .
    ```

    For example, if your Docker username was `mobydock`, you would run the following:

    ```console
    $ docker build -t mobydock/getting-started-todo-app .
    ```

3. To verify the image exists locally, you can use the `docker image ls` command:

    ```console
    $ docker image ls
    ```

    You will see output similar to the following:

    ```console
    REPOSITORY                          TAG       IMAGE ID       CREATED          SIZE
    mobydock/getting-started-todo-app   latest    1543656c9290   2 minutes ago    1.12GB
    ...
    ```

4. To push the image, use the `docker push` command. Be sure to replace `DOCKER_USERNAME` with your username:

    ```console
    $ docker push <DOCKER_USERNAME>/getting-started-todo-app
    ```

    Depending on your upload speeds, this may take a moment to push.

{{< /tab >}}
{{< tab name="VS Code" >}}

1. Open Visual Studio Code. Ensure you have the **Docker extension for VS Code** installed from [Extension Marketplace](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-docker).

Title: Creating a Docker Hub Repository and Building/Pushing the Image
Summary
This section guides you through creating an image repository on Docker Hub and then building and pushing a Docker image. It explains that the image extends the Node image, simplifying the process. A Dockerfile is introduced as a text-based script with instructions on how to build the image. The guide provides command-line instructions to clone the project, build the image, verify its existence locally, and then push it to Docker Hub. VS Code instructions are mentioned, requiring the Docker extension.