What's your way of running 'git clone' with RancherOS?

I’d like to give ROS a try, but I’m facing some “philosophical” issues due to its very peculiar arch.

I have an online git repository with code, Dockerfile and docker-compose.yml to pop up a multy tier docker infrastructure.

I need to run “git clone” at first, to get a persistent directory with all the code in my repo, from where running “docker-compose up” to start the all infrastructure.

How can I do that ? What is RancherOS way here ?

@lgs

I make it to run a git container as local command, so you needn’t deal with the package manager, such as apt-get, yum or apk, etc. It’s only 22MB and build on alpine linux.

usage

alias git="docker run -ti --rm -v $(pwd):/git bwits/docker-git-alpine"

For example, if you need clone this repository, with the alias you just set, you can run it as local command

git --help
git clone https://github.com/BWITS/docker-git-alpine.git
ls docker-git-alpine

Only recommend to clone the git repository with https url to avoid ssh key setup

5 Likes

For those coming from Google, RancherOS does not have a /home/rancher/.profile file for you to add aliases, so you will need to create it first.

sudo vi /home/rancheros/.profile then paste and :wq.

Change from double quotes to single quote can make $(pwd) works for the alias line.
Or escape it like \$(pwd) with double quotes.

do you mean sudo vi /home/rancher/.profile ?
How do you deal with PATH ?

For those coming from Google (like me)
another solution is here : GitHub - alpine-docker/git: A useful simple git container running in alpine linux, especially for tiny linux distro, such as RancherOS, which don't have package manager.

$ cat ~/.profile
...
function git () {
    (docker run -ti --rm -v ${HOME}:/home/rancher -v $(pwd):/git alpine/git "$@")
}
...

$ source ~/.profile