项目作者: felipecruz91

项目描述 :
Push Docker image to DockerHub
高级语言: Java
项目地址: git://github.com/felipecruz91/push-to-dockerhub.git
创建时间: 2020-01-12T17:00:39Z
项目社区:https://github.com/felipecruz91/push-to-dockerhub

开源协议:MIT License

下载


push-to-dockerhub

Create an account in Docker Hub

Sign up in Docker Hub to create a Docker ID. You will need this in order to create a repository and push Docker images to it.

Create a private repository

Create a private repository in Docker Hub with name webapp:

create-repo

Log into a Docker registry

  1. $ docker login
  2. Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
  3. Username: felipecruz
  4. Password: ********
  5. WARNING! Your password will be stored unencrypted in /home/felipe/.docker/config.json.
  6. Configure a credential helper to remove this warning. See
  7. https://docs.docker.com/engine/reference/commandline/login/#credentials-store
  8. Login Succeeded

Build your image

Build your java web app locally using the given Dockerfile.

  1. $ docker build -t webapp .

Tag your image

  1. $ docker tag webapp felipecruz/webapp

Push your image:

  1. $ docker push felipecruz/webapp
  2. The push refers to repository [docker.io/felipecruz/webapp]
  3. 60d67f8af71d: Pushed
  4. 290cec21aafb: Mounted from library/openjdk
  5. e7f8b07649a4: Mounted from library/openjdk
  6. 109e67eff29c: Mounted from library/openjdk
  7. 556c5fb0d91b: Mounted from library/redis
  8. latest: digest: sha256:70d75c2e9b2e004b296659742681da771e125153e5dada3ae1d5a721355c9bbe size: 1371

Anyone that is a collaborator in your repository can pull your image. Feel free to add some of your colleagues as collaborators through the Docker Hub web so that they can pull and run your image too!

collaborators

Finally, you can pull the image and run it as a container with the following command:

  1. $ docker run --name webapp --rm -d -p 3000:8080 felipecruz/webapp:latest

Visit http://localhost:3000/ and you should see the message:

Handling request from <container-id> by Felipe

Clean up

  1. $ docker stop webapp