Pushing Images

Let’s publish a Docker image to Docker Hub so that anyone (or any server) can pull it down and run it.

To push an image, it must be tagged with a name that corresponds to your namespace on Docker Hub. If your Docker Hub username is janedoe, your images must be named janedoe/image-name.

  1. Build the image with your namespace:

    # Replace USERNAME with your Docker Hub username
    docker build . -t USERNAME/goserver
  2. Verify it works locally:

    docker run -p 8991:8991 USERNAME/goserver
  3. Push the image to Docker Hub:

    docker push USERNAME/goserver

(Note: You must be logged in via docker login for this to work.)

If everything worked, you should be able to refresh your repositories page on Docker Hub and see your new image! By default, Docker Hub makes your images public, so anyone can pull them.