2016-07-29

Dev Environment Workaround For Over Sized TLS on Mac

Basically I was experimenting something with my local repo and I was quite disappointed when I couldn't upload images I built to my locally running repo. I just couldn't get passed this error:

    $ docker push $(docker-machine ip default):5000/test:0.1
    The push refers to a repository [192.168.99.100:5000/test]
    unable to ping registry endpoint https://192.168.99.100:5000/v0/
    v2 ping attempt failed with error: 
        Get https://192.168.99.100:5000/v2/: tls:
        oversized record received with length 20527
    v1 ping attempt failed with error: 
        Get https://192.168.99.100:5000/v1/_ping: 
        tls: oversized record received with length 20527
    
After giving this some thought I decided to combine a few online recipes. If you ended up finding this post you probably know enough to find your way around docker-machine command for mac. There's a big buzz at the moment about native docker support. But doing it with docker machine might still prove useful to someone. The difference between a side note and a blog post is not that big anyway. So I'll give it a go :)

Start a registry in the first machine

        $ docker-machine start default
        $ eval $(docker-machine env default)
        $ echo $(docker-machine ip default)
        192.168.99.100
        $docker run -d -p 5000:5000 registry:2
    
The only thing you need to remember here is the displayed IP address.

Start another machine that allows insecure registry

Simply open a new tab in your terminal and start a new machine with this command:

        $ docker-machine create --driver=virtualbox \
           --engine-insecure-registry 192.168.99.100:5000 dev
    
After you finish creating a machine run the rest of the usual docker mac combo commands:
        $ eval $(docker-machine env dev)
    

Build and tag your image and push it to your local repo (second tab)

Build your image the usual way. Tag it with whatever you think is suitable. And push your image to the repository.

        $ docker build -t msvaljek/test:0.1 .

        $ docker tag \
          msvaljek/test:0.1 $(docker-machine ip default):5000/test:0.1

        $ docker push $(docker-machine ip default):5000/test:0.1
        The push refers to a repository [192.168.99.100:5000/test]
        4e775ea8c828: Pushed
        d911d0794978: Pushed
        9dccf4ea77d4: Pushed
        19c45a2a4d46: Pushed
        e7039e485d0f: Pushed
        538e83a54f2a: Pushed
        6c77cc0af681: Pushed
        90022d1ffd75: Pushed
        ec0200a19d76: Pushed
        338cb8e0e9ed: Pushed
        d1c800db26c7: Pushed
        42755cf4ee95: Pushed
        0.1: digest: sha256:52fbaba4af0fd3e949adea1b2386b7e17e2820a
        b1ac4b2a4e7773863bee5c1e9 size: 2834
    
That's it I hope it helps someone ;). Once again, this is not some sort of a best practice, its more of a quick fix for local dev machines in secure environments :)

No comments: