|
| 1 | +# Image registries |
| 2 | + |
| 3 | +There are several places where you can store your docker image. In this section, we cover some of the most known ones. |
| 4 | +However, you can use any other of your preference. |
| 5 | + |
| 6 | +!!! warning "Build your image before hand" |
| 7 | + In the following documentation we are assuming that you have already built your docker image. |
| 8 | + You can find documentation on how to do it [here](./image.md). |
| 9 | + |
| 10 | +## DockerHub |
| 11 | + |
| 12 | +To use docker hub, follow Docker's [official documentation](https://docs.docker.com/docker-hub/repos/). |
| 13 | + |
| 14 | +## GitHub |
| 15 | + |
| 16 | +To store your image in GitHub you will need a repository. You can use your instance's one. For example: |
| 17 | +*https://github/yourusername/rdmrepo*. In addition, you will need to [create an access token](https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line). This access token must have |
| 18 | +`read:packages` and `write:packages` scopes. |
| 19 | + |
| 20 | +The first step is to login in GitHub's docker registry: |
| 21 | + |
| 22 | +``` console |
| 23 | +$ docker login docker.pkg.github.com -u <YOU_GITHUB_USERNAME> -p <YOUR_GITHUB_TOKEN> |
| 24 | +``` |
| 25 | + |
| 26 | +Then find your docker image and tag it you the url of your GitHub registry: |
| 27 | + |
| 28 | +``` |
| 29 | +$ docker images |
| 30 | +REPOSITORY TAG IMAGE ID CREATED SIZE |
| 31 | +demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB |
| 32 | +
|
| 33 | +$ docker tag demo-inveniordm docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest |
| 34 | +``` |
| 35 | + |
| 36 | +!!! info "Project name" |
| 37 | + Note that `rdmrepo` is the name of your GitHub repository. Therefore the tag is: ``docker.pkg.github.co/<your_github_user_name>/<your_github_repo_name>/<your_image_name>:<version>`` |
| 38 | + |
| 39 | +Check that it was tagged correctly: |
| 40 | + |
| 41 | +``` console |
| 42 | +$ docker images |
| 43 | +REPOSITORY TAG IMAGE ID CREATED SIZE |
| 44 | +demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB |
| 45 | +docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest latest 9b6dd5ae6b48 17 hours ago 2.33GB |
| 46 | +``` |
| 47 | + |
| 48 | +The last step is to push your package to the github registry: |
| 49 | + |
| 50 | +``` console |
| 51 | +docker push docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest |
| 52 | +``` |
| 53 | + |
| 54 | +In order to use this image, you must set the following value in your `values.yaml` file (for both `web` and `worker`): |
| 55 | + |
| 56 | +``` |
| 57 | +image: docker.pkg.github.com/yourusername/rdmrepo/rdmimage:latest |
| 58 | +``` |
| 59 | + |
| 60 | +Even if your project and/or image is public, GitHub requires you to be authenticated in order to pull your image. |
| 61 | +In OpenShift you can change the default pulling configuration so that it uses your token. You can do so as follows: |
| 62 | + |
| 63 | +``` console |
| 64 | +$ oc create secret docker-registry <SECRET_NAME> \ |
| 65 | + --docker-server=docker.pkg.github.com \ |
| 66 | + --docker-username=<YOUR_GITHUB_USERNAME> \ |
| 67 | + --docker-password=<YOUR_GITHUB_PASSWORD> |
| 68 | +$ oc secrets link default <SECRET_NAME> --for=pull \ |
| 69 | + --namespace=<YOUR_OPENSHIFT_PROJECT_NAME> |
| 70 | +``` |
| 71 | + |
| 72 | +## OpenShift |
| 73 | + |
| 74 | +First you need to login in your OpenShift cluster and its image registry: |
| 75 | + |
| 76 | +``` console |
| 77 | +$ docker login -u openshift -p $(oc whoami -t) <registry_ip>:<port> |
| 78 | +$ oc login |
| 79 | +$ oc project |
| 80 | +Using project "inveniordm" on server "<registry_ip>:<port>". |
| 81 | +``` |
| 82 | + |
| 83 | +Then find your docker image and tag it you the url of your OpenShift registry: |
| 84 | + |
| 85 | +``` console |
| 86 | +$ docker images |
| 87 | +REPOSITORY TAG IMAGE ID CREATED SIZE |
| 88 | +demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB |
| 89 | + |
| 90 | +$ docker tag demo-inveniordm <registry_ip>:<port>/inveniordm/demo-inveniordm:latest |
| 91 | +``` |
| 92 | + |
| 93 | +!!! info "Project name" |
| 94 | + Note that `inveniordm` is the name of the OpenShift project we are using. It's value should be the one returned |
| 95 | + by the `oc project` command. Therefore the tag is: ``<registry_ip>:<port>/<project_name>/<name_of_your_image>:<version>`` |
| 96 | + |
| 97 | +Check that it was tagged correctly: |
| 98 | + |
| 99 | +``` console |
| 100 | +$ docker images |
| 101 | +REPOSITORY TAG IMAGE ID CREATED SIZE |
| 102 | +demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB |
| 103 | +<registry_ip>:<port>/inveniordm/demo-inveniordm latest 9b6dd5ae6b48 17 hours ago 2.33GB |
| 104 | +``` |
| 105 | + |
| 106 | +Finally push it to the image registry of OpenShift: |
| 107 | + |
| 108 | +``` console |
| 109 | +$ docker push <registry_ip>:<port>/inveniordm/demo-inveniordm:latest |
| 110 | +``` |
| 111 | + |
| 112 | +In order to use this image, you must set the following value in your `values.yaml` file (for both `web` and `worker`): |
| 113 | + |
| 114 | +``` console |
| 115 | +image: <registry_ip>:<port>/inveniordm/demo-inveniordm:rdm |
| 116 | +``` |
0 commit comments