Giter Club home page Giter Club logo

remote-docker's Introduction

remote-docker

Build

Codefresh build status

Image

A Docker container to securely control a remote docker daemon CLI using ssh forwarding, no SSL setup needed.

Setup

In order to use remote-docker with your Docker server, you need to configure SSH-key based authentication for your Docker server machine. There are lots of tutorials available: you can use this for example.

You should add you SSH public key to your Docker server and keep private key for using in remote-docker container. You can pass this key either as file (using -v option) or as environment variable (-e SSH_KEY=...).

From now on, you should be able to run any docker command on your server through SSH tunneling.

Usage

Lets assume you want to control the docker daemon on your webserver.com server. You need to run a codefresh/remote-docker Docker container, passing ssh private key file to it, like this:

$ docker run -it --rm -v ${HOME}/.ssh/id_rdocker:/root/.ssh/id_rdocker codefresh/remote-docker rdocker [email protected]

Or you can pass ssh key as the environment variable (assuming you've setup SSH_KEY)

$ docker run -it --rm -e SSH-KEY=${SSH_KEY} codefresh/remote-docker rdocker [email protected]

This will open a new bash session, within the codefresh/remote-docker container, with a new DOCKER_HOST variable setup. Any docker command you execute will take place on the remote docker daemon. To test the connection run:

docker:[email protected] bash-4.3# docker info

Check the Name: field it should have the remote hostname .... That's it!!!

You could for example run docker build to build an image on the remote host and then docker save -o myimage.tar image_name to store it locally. Or run docker exec -it container_name bash to open a shell session on a remote container. Even bash auto-completion works ok.

To stop controlling the remote daemon and close the ssh forwarding, just exit the newly created bash session (press Ctrl+D).

You can also execute any docker command directly, without openning a bash shell in the codefresh/remote-docker container.

$ docker run -it --rm -v ${HOME}/.ssh/id_rdocker:/root/.ssh/id_rdocker codefresh/remote-docker rdocker [email protected] docker info

Custom SSH port

Redefine SSH_PORT environment variable if you are using a different port than 22 (set by default).

Used software

remote-docker's People

Contributors

alexei-led avatar amir-codefresh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

remote-docker's Issues

unsupported Compose file version: 3.7 (please support this soon)

What I am trying to do

Deploy Docker Swarm with Codefresh
I am following these step: https://codefresh.io/docs/docs/deploy-your-containers/docker-swarm/
image

A bit more background info

I am using a sample Ruby on Rails 5 app (create with rails new ...etc)
because I am trying if codefresh work for me. if it doesn't, I am gonna use Buddy
I am trying to build a CI/CD workflow with Github -> CodeFresh -> Docker Swarm(it run on my Azure machine)

What actually happen

Error message: unsupported Compose file version: 3.4
image

codefresh.yml

image
the point here is I am using codefresh/remote-docker image.
I know the - docker info and - rdocker help doesn't work, I already remove them. I am just trying to debug issue with these 2 line.

docker-stack.yml

image
the screenshot here showing 3.7 but previous image showing 3.4 because I take screenshot after create this issue, I can't find that 3.7 error log. so I just screenshot that 3.4 error as example

both version 3.4 and version 3.7 not working

I guess you guys are focusing on Kubenetes?
I am trying to deploy with Docker swarm.

getting "sh: python: not found"

Running this command
docker run -it --rm -v /Users/.ssh/id_rsa:/root/.ssh/id_rdocker codefresh/remote-docker rdocker docker@XXXXXX

And getting this error "sh: python: not found"

python: can't open file '/tmp/rdocker-forwarder.py': [Errno 2] No such file or directory

I am using codefresh.io to build and deploy to my "Docker Swarm for AWS" running on AWS.

I've noticed that the Linux setup inside these Docker nodes is minimal. They didn't have python installed; so I installed python already.

My test deploys were working months ago; but now that I have come back to the same setup, I am getting the following error during the rdocker deploys:

Status: Downloaded newer image for codefresh/remote-docker:latest
SSH key passed through SSH_KEY environment variable: lenght check 1674
Warning: Permanently added '--removed--' (ECDSA) to the list of known hosts.
bind: Address not available
python: can't open file '/tmp/rdocker-forwarder.py': [Errno 2] No such file or directory
/usr/local/bin/rdocker: line 156: read: read error: 3: Resource temporarily unavailable
[SYSTEM] Error: Failed to run freestyle step: Running Deploy Script; caused by NonZeroExitCodeError: Cont
ainer for step title: Running Deploy Script, step type: freestyle, operation: Freestyle step failed with
exit code: 1

Could you help me figure out what isn't working?

Thank you!!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.