-1

Alright, so I am trying to publish a private docker image to kubernetes, and I am running into some odd issues.

I start of with logging into docker

docker login -u $DOCKER_USER -p $DOCKER_TOKEN 

and that will store my password in a config file for me, so I run this

kubectl create secret generic regcred --from-file=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson

I would expect that to pick up the url in the config.json file, but I get this error

The connection to the server localhost:8080 was refused - did you specify the right host or port?

So I thought that I might as well specify the server

kubectl create secret generic regcred --from-file=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson --server=https://index.docker.io/v1/

But still no luck.

error: EOF
2020-01-12T19:45:39.7433187Z stdout P Please enter Username:

and since this is running on a build server, I cannot enter the username.

So what am I missing here?

munHunger
  • 363
  • 1
  • 3
  • 9
  • Hi, what is your infrastructure? Could You check by `kubectl get all -A` if your cluster is working properly? Can You create any pod by using kubectl run/create or the same problem occurs? Maybe try create a secret by providing credentials on the [command line](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#create-a-secret-by-providing-credentials-on-the-command-line)? – Jakub Jan 13 '20 at 09:28

1 Answers1

0

kubectl create secret generic regcred --from-file=/root/.docker/config.json --type=kubernetes.io/dockerconfigjson --server=https://index.docker.io/v1/

You are conflating the --server= argument to kubectl, which determines the kubernetes server to which it will connect, with --docker-server=

You will want to use the provided kubectl create secret docker-registry command (versus the generic type) because the Secret that is created by the specialized version is not just the .docker/config.json file uploaded to the cluster -- they are structurally different

Also:

The connection to the server localhost:8080 was refused - did you specify the right host or port?

is a dead giveaway that you do not have a correctly configured kubeconfig so you can forget about any kubectl command doing anything reasonable until you fix that problem

mdaniel
  • 2,561
  • 1
  • 9
  • 13