how to create a Docker local private repository - docker

I created a local docker repository in my server. When I try to push the image into it, there is an error. I need an HTTPS connection. How do I get an HTTPS for my own docker registry?
os: ubuntu 16.x
Docker version: 18.06.1-ce, build e68fc7a
Already Tried:
Adding the below lines into /etc/docker/daemon.json,
{
"insecure-registries" : ["myregistrydomain.com:5000"]
}
Expected: I should be able to push and pull images into my own server containing docker registry

To avoid exposing your registry to the wider internet while still being able to pull images from it you can:
Run a local registry on your dev machine, to which you push images
ssh to your server with a reverse tunnel:
ssh -R 5000:localhost:5000 myhost
(listen on port 5000 of the remote machine (-R 5000) and tunnel back to localhost:5000 on the local machine)
Now, on myhost you can docker pull localhost:5000/someImage, but it's actually seamlessly connecting through an encrypted tunnel back to the registry on your dev machine.

You can have a local unsecured registry.
For that, you need to add an exception in your /etc/docker/daemon.json, this way
{
"insecure-registries" : ["myregistrydomain.com:5000"]
}
The same link shows how to use a self-signed certificate.
Eventually, using an actual certificate is juste a step further, but you may not need one for development purpose.
EDIT :
You need to restart your daemon after that :
service docker restart

Related

Unable to login to private docker registry from Jenkins

I am trying to use Jenkins to build and push docker images to private registry. However, while trying docker login command, I am getting this error:
http: server gave HTTP response to HTTPS client
I know that this might be happening because the private registry is not added as an insecure registry. But, how I can resolve this in CI pipeline?
Jenkins is set up on a Kubernetes cluster and I am trying to automate the deployment of an application on the cluster.
This has nothing to do with the Jenkins CI pipeline or Kubernetes. Jenkins will not be able to push your images until configure follow either of the below steps
You have two options here
1) Configure your docker client to use the secure registry over HTTPS. This will include setting up self signed certificates or getting certificates from your local certificate authority.
2) Second solution is to use your registry over an unencrypted HTTP connection.
So if you are running docker on kubernetes. You will have to configure the daemon.json file in /etc/docker/daemon.json.
PS: This file might not exist. You will have to create it.
Then add in the below content. Make sure you change the url to match your docker registry
{
"insecure-registries" : ["myregistrydomain.com:5000"]
}
Then restart docker using systemctl restart docker or etc/init.d/docker restart depending on the version of linux distro installed on your cluster
Let me know if you have any questions

In virtual-machine Docker push to private registry failed under proxy

I want to push a Docker image to a private registry in the local machine.
The docker is running in a virtual-machine CentOS 7 and I'm working a in a network under a proxy.
What I did is to tag my Docker local image "test_bench_image" obtained from building a dockerfile:
docker tag test_bench_image localhost:5000/test_bench_image
and then I tried to push it:
docker push localhost:5000/test_bench_image
What I get is:
The push refers to a repository [localhost:5000/test_bench_image]
Put http://localhost:5000/v1/repositories/test_bench_image/: dial tcp 127.0.0.1:5000: getsockopt: connection refused
I understood that /etc/sysconfig/docker should include the variable no_proxy to allow pushing to private Docker registry under a proxy. So I included in the file:
...
http_proxy="http://myproxy.es:80"
https_proxy="http://myproxy.es:80"
no_proxy="127.0.0.1:5000"
But I get the same error message after reload the daemon and restart the docker service.
Any help will be really welcome.
Note: My original plan was to use the Docker local image in Jenkins. But the Docker plugin cannot pull the local image since it is not publicly available. So I tried to create a private registry and force Jenkins to pull it from there.
Thanks.
I ran into a similar issue and I had to additionally uncomment and add my private registry's host IP in the section INSECURE_REGISTRY='XX.XXX.XXX.XXX:5000' in /etc/sysconfig/docker file.

Error: Status 404 trying to push repository busybox

I tried to push signed images from a machine (A) to a registry on another machine (B).
docker tag busybox:latest ubuntu:5005/busybox:latest
docker push ubuntu:5005/busybox:latest
The push refers to a repository [ubuntu:5005/busybox] .... Error: Status 404 trying to push repository busybox ... .
telnet ubuntu 5005
Trying 127.0.1.1...
telnet: Unable to connect to remote host: Connection refused
Are there any extra settings in order to push signed images on a diff machine. Or just to push without signing? Thanks a lot!
If you can't reach this, make sure your ports are properly exposed on the machine and that your networking resolves "ubuntu" to your newest machine correctly.
It's probable Machine A has no rule allowing ubuntu to resolve to <machine B>.
Make sure you docker login as well once you verify this, too.
This docs helped me to solve the problem.
https://docs.docker.com/registry/insecure/.
https://docs.docker.com/registry/deploying/#get-a-certificate.
https://www.digitalocean.com/community/tutorials/how-to-set-up-a-private-docker-registry-on-ubuntu-14-04.

Rancher can pull images from private registry

I have create a private registry by harbor.
but when I use rancher to update a container, rancher can not pull images.
before this registry.ziztour.com is normal operation.
Rancher registries:
Error:
Manually pull my private registry image successful:
rancher v1.1.0
docker v1.11.2
Better late than never, but when I had issues pulling from a secure registry I solved the issue by creating/modifying the etc/docker/daemon.json file on the rancher server and all rancher hosts and adding the following.
{
"insecure-registries" : [
"<registry-1-ip>",
"<registry-2-ip>"
]
}
Once you've done this run sudo service docker restart
When you add the ip's leave the http:// or https:// off.
Make sure you do this on all your rancher hosts as well as on the rancher server, otherwise it won't work.

accessing docker private registry

I have my private docker registry running on a remote machine, which is secured by TLS and uses HTTPS. Now I want to access it from my local docker-machine installed on Windows 7. I have copied the certificates to "/etc/docker/certs.d/" in the docker-machine VM and restarted docker.
After this I can successfully login to my private registry using credentials, but when I try to push an image to it, it gives me a certificate signed by unknown authority error. After researching a little I restarted the docker daemon with docker -d --insecure-registry https://<registry-host>, and it worked.
My question is: if I have copied my certificates to the host machine, why do I need to start the registry with the --insecure-registry option?
I can only access the registry from another host with certificates as well as restarting docker with --insecure-registry , which looks a little wrong to me.
Docker version: 1.8.3
Any pointers on this would be really helpful.
certificate signed by unknown authority
The error message gives it away - your certificates are self-signed (as in not trusted by a known CA).
See here.
If you would like to access your registry with HTTP, follow the instructions here
Basically (do this on the machine from which you try to access the registry):
edit the file /etc/default/docker so that there is a line that reads: DOCKER_OPTS="--insecure-registry myregistrydomain.com:5000" (or add that to existing DOCKER_OPTS)
restart your Docker daemon: on ubuntu, this is usually service docker stop && service docker start

Resources