Skip to content

Build an Image with Docker and Push to a Container Registry

Kim Schlesinger edited this page May 24, 2021 · 1 revision

Build an Image with Docker and Push it to a Container Registry

Prereqs:

  • Docker is installed and running on your machine
    • Check with docker --version
    • Get fancy with docker info
  • Build an app and create a Dockerfile

How to do it

  1. Create a Docker image
  • In the directory for your app run

    docker build -t <nameofimage> .

  1. Test that it's working by creating a container locally

    docker run -p 4000:80 <nameofimage>

  2. Login in your registry

  • For Dockerhub: docker login
  • For DOCR: doctl registry login
  1. Tag your image with your registry and repo name

    docker tag <my-image> registry.digitalocean.com/<my-registry>/<my-image>:tag

  2. Upload your image to your registry

    docker push registry.digitalocean.com/<my-registry>/<my-image>

  3. Repeat and update the tag when a change is made

  4. Have a cookie.

Clone this wiki locally