Closed shubhrojyotide closed 4 years ago
[shubhrojyotide@oc8740175532 DockerFiles]$ ibmcloud ks cluster config --cluster brdro49d0egltrb3t8h0 OK The configuration for brdro49d0egltrb3t8h0 was downloaded successfully.
Added context for brdro49d0egltrb3t8h0 to the current kubeconfig file. You can now execute 'kubectl' commands against your cluster. For example, run 'kubectl get nodes'. [shubhrojyotide@oc8740175532 DockerFiles]$ kubectl config current-context K8-Cluster-Shubhro/brdro49d0egltrb3t8h0 [shubhrojyotide@oc8740175532 DockerFiles]$ kubectl run hello-world --image=us.icr.io/k8-ns-shubhro/hello-world:1 error: You must be logged in to the server (Unauthorized) [shubhrojyotide@oc8740175532 DockerFiles]$ kubectl create deployment hello-world --image=us.icr.io/k8-ns-shubhro/hello-world:1 error: failed to discover supported resources: Unauthorized
[shubhrojyotide@oc8740175532 DockerFiles]$ docker push us.icr.io/k8-ns-shubhro/hello-world The push refers to a repository [us.icr.io/k8-ns-shubhro/hello-world] 9c27e219663c: Preparing unauthorized: authentication required
Solution : i had to login in like this...
[shubhrojyotide@oc8740175532 DockerFiles]$ ibmcloud cr login Logging in to 'registry.ng.bluemix.net'... Logged in to 'registry.ng.bluemix.net'.
Logging in to 'us.icr.io'... Logged in to 'us.icr.io'.
OK [shubhrojyotide@oc8740175532 DockerFiles]$ docker push us.icr.io/k8-ns-shubhro/hello-world:1 The push refers to a repository [us.icr.io/k8-ns-shubhro/hello-world] 9c27e219663c: Pushed 1: digest: sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042 size: 525
[shubhrojyotide@oc8740175532 Desktop]$ ls -ltr |grep -i docker drwxrwxr-x. 2 shubhrojyotide shubhrojyotide 4096 May 11 00:03 DockerFiles [shubhrojyotide@oc8740175532 Desktop]$ cd DockerFiles
[shubhrojyotide@oc8740175532 DockerFiles]$ ls -ltr total 4 -rw-rw-r--. 1 shubhrojyotide shubhrojyotide 153 May 11 00:03 Dockerfile
[shubhrojyotide@oc8740175532 DockerFiles]$ cat Dockerfile FROM ubuntu MAINTAINER Shubhrojyoti De RUN apt-get update CMD ["echo", "Hello World .. This is my first docker image"]
[shubhrojyotide@oc8740175532 DockerFiles]$ docker build --tag us.icr.io/k8-ns-shubhro/hello-world "docker build" requires exactly 1 argument(s). See 'docker build --help'. Usage: docker build [OPTIONS] PATH | URL | - Build an image from a Dockerfile
[shubhrojyotide@oc8740175532 DockerFiles]$ docker build --tag us.icr.io/k8-ns-shubhro/hello-world . Sending build context to Docker daemon 2.048 kB Step 1/4 : FROM ubuntu Trying to pull repository docker.io/library/ubuntu ... latest: Pulling from docker.io/library/ubuntu d51af753c3d3: Downloading [======> ] 3.808 MB/28.56 MB fc878cd0a91c: Download complete 6154df8ff988: Download complete fee5db0ff82f: Download complete d51af753c3d3: Pull complete fc878cd0a91c: Pull complete 6154df8ff988: Pull complete fee5db0ff82f: Pull complete Digest: sha256:747d2dbbaaee995098c9792d99bd333c6783ce56150d1b11e333bbceed5c54d7 Status: Downloaded newer image for docker.io/ubuntu:latest ---> 1d622ef86b13 Step 2/4 : MAINTAINER Shubhrojyoti De ---> Running in d446c75b4d86 ---> 73a79e6fd4f6 Removing intermediate container d446c75b4d86 Step 3/4 : RUN apt-get update ---> Running in f85be82b9866 Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [107 kB] Get:2 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB] Get:3 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [10.6 kB] Get:4 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [39.8 kB] Get:5 http://archive.ubuntu.com/ubuntu focal-updates InRelease [107 kB] Get:6 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [1079 B] Get:7 http://archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB] Get:8 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [117 kB] Get:9 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB] Get:10 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB] Get:11 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB] Get:12 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB] Get:13 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [126 kB] Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [224 kB] Get:15 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [10.6 kB] Get:16 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [1079 B] Get:17 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [2903 B] Fetched 13.9 MB in 1min 19s (176 kB/s) Reading package lists... ---> d9f3fd11769f Removing intermediate container f85be82b9866 Step 4/4 : CMD echo Hello World .. This is my first docker image ---> Running in 1105ac985719 ---> cae5ae9c5674 Removing intermediate container 1105ac985719 Successfully built cae5ae9c5674 [shubhrojyotide@oc8740175532 DockerFiles]$
[shubhrojyotide@oc8740175532 DockerFiles]$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE us.icr.io/k8-ns-shubhro/hello-world latest cae5ae9c5674 4 minutes ago 95.8 MB docker.io/ubuntu latest 1d622ef86b13 6 weeks ago 73.9 MB docker.io/hello-world latest bf756fb1ae65 5 months ago 13.3 kB
But again the problem comes here :
[shubhrojyotide@oc8740175532 DockerFiles]$ docker push us.icr.io/k8-ns-shubhro/hello-world:1 The push refers to a repository [us.icr.io/k8-ns-shubhro/hello-world] d7fc1756ca5c: Preparing 8891751e0a17: Preparing 2a19bd70fcd4: Preparing 9e53fd489559: Preparing 7789f1a3d4e9: Preparing unauthorized: authentication required
Any idea how to fix this ?