Home Explore Blog CI



docker

3rd chunk of `content/get-started/introduction/build-and-push-first-image.md`
f7830db33967e0a270f3a3bcb4e608d94d01dbf520833547000000010000087c
    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).

   ![Screenshot of VS code extension marketplace](images/install-docker-extension.webp)

2. In the **File** menu, select **Open Folder**. Choose **Clone Git Repository** and paste this URL: [https://github.com/docker/getting-started-todo-app](https://github.com/docker/getting-started-todo-app)

    ![Screenshot of VS code showing how to clone a repository](images/clone-the-repo.webp?border=true)



3. Right-click the `Dockerfile` and select the **Build Image...** menu item.


    ![Screenshot of VS Code showing the right-click menu and "Build Image" menu item](images/build-vscode-menu-item.webp?border=true)

4. In the dialog that appears, enter a name of `DOCKER_USERNAME/getting-started-todo-app`, replacing `DOCKER_USERNAME` with your Docker username. 

5. After pressing **Enter**, you'll see a terminal appear where the build will occur. Once it's completed, feel free to close the terminal.

6. Open the Docker Extension for VS Code by selecting the Docker logo in the left nav menu.

7. Find the image you created. It'll have a name of `docker.io/DOCKER_USERNAME/getting-started-todo-app`. 

Title: Building and Pushing the Image (CLI and VS Code)
Summary
This section continues the guide on building and pushing a Docker image. It provides specific commands for both CLI and VS Code. For CLI, it demonstrates how to verify the image exists locally using `docker image ls` and how to push the image to Docker Hub using `docker push`. For VS Code, it instructs on opening the project, building the image via the Docker extension, and finding the image in the Docker extension.