Build and Push Docker images to Docker hub registry

Requirements: Should read first the blog Dockerize Simple .Net Core API in order for us to have the image that we are going to push to docker hub.

This can be done by just three simple steps:

  1. docker login --username username
    • prompts for password if you omit --password which is recommended as it doesn’t store it in your command history
  2. docker tag [my-image] [username]/[my-repo]
  3. docker push [username]/[my-repo]
$ docker images simplecoreapi:1.0.0
REPOSITORY      TAG       IMAGE ID       CREATED      SIZE
simplecoreapi   1.0.0     a1331de58861   7 days ago   216MB

$ docker tag simplecoreapi:1.0.0 sandboxdaily/simplecoreapi:1.0.0

$ docker push sandboxdaily/simplecoreapi:1.0.0
The push refers to repository [docker.io/sandboxdaily/simplecoreapi]
29711468928e: Pushed 
5f70bf18a086: Pushed 
4c34327942ed: Pushed 
8477b0b568ed: Pushed 
59dddc57d588: Pushed 
140ec22ac653: Pushed 
4ddf8cdb4013: Pushed 
e699a0ffa56a: Pushed 
1.0.0: digest: sha256:bf216e80f8d9180f83b8ebcb71e002fed0e9055c9bd2d15a52e20396aedc5c3d size: 1994

$ docker run -d -p 2439:80 --name sandbox.simplecoreapi sandboxdaily/simplecoreapi:1.0.0
673348fd816309cbd5b4e2e0f2948eafdf6cb60dbecb0db265d96e95a64ed98c

$ curl http://localhost:2439/api/values
{"machineName":"673348fd8163","environment":null,"logJsonPath":"payloads-base"}

Leave a Reply

Your email address will not be published. Required fields are marked *

footer