Oh, did you know that? Showing info about Git workflow:
> git help workflows
This prints a nice overview about the Git workflow:
GITWORKFLOWS(7) Git Manual GITWORKFLOWS(7)
NAME
gitworkflows - An overview of recommended workflows with Git
SYNOPSIS
git *
DESCRIPTION
This document attempts to write down and motivate some of the workflow elements used for git.git itself. Many ideas apply in general,
though the full workflow is rarely required for smaller projects with fewer people involved.
We formulate a set of rules for quick reference, while the prose tries to motivate each of them. Do not always take them literally; you
should value good reasons for your actions higher than manpages such as this one.
[...]
Some GIT basics mainly for me to remember. I use Google Drive as a poor man solution to
share some Java test projects between my work place and my home. And that's how I have done it.
First, init the (local) repository at Google Drive. On MacOS, the directory can be found
at ~/Google\ Drive/:
cd ~/Google\ Drive/
mkdir projects
cd projects
mkdir my_project.git
cd my_project.git
git init --bare
In the test project workspace, a project is added to the repository as follows:
varexpress=require('express');varDEFAULT_PORT=8080;varPORT=process.env.PORT||DEFAULT_PORT;varapp=express();app.get('/',function(req,res){res.send('Hello World\n');});app.listen(PORT)console.log('Running on http://localhost:'+PORT);
{"name":"docker-centos-hello-world","private":true,"version":"0.0.1","description":"Node.js Hello World app on CentOS using docker","author":"Daniel Gasienica","dependencies":{"express":"3.2.4"}}
FROM centos:6.4
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
RUN yum install -y npm
ADD . /src
RUN cd /src; npm install
EXPOSE 8080
CMD ["node", "/src/index.js"]
The layout of your directory should be as follows:
> ls
Dockerfile index.js package.json
Building the image:
docker build -t peter/centos-node-hello .
Verify if the image exists:
docker images
This should print:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
peter/centos-node-hello latest 6c55823e6868 4 hours ago 672.2 MB
3. Running
docker run -p 49160:8080 -d peter/centos-node-hello
The option -p exposes the port 8080 to 49160. This is essential. Without that, the server is not visible to a client.
Verify, if the process is running:
docker ps
You should see:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
578bd01b0407 peter/centos-node-hello:latest node /src/index.js 4 hours ago Up 2 hours 0.0.0.0:49160->8080/tcp jovial_feynman
Inspect the image:
docker inspect 578bd01b0407
You should see a JSON output showing all relevant information:
If the -p was not given when starting the process, HostPort would have been null and the application would not have been visible to clients. Test it:
curl localhost:49160
Now you should see:
Hello World.
Stop and start the process again:
docker stop 578bd01b0407
docker ps doesn't show the process any more. docker ps -a lists the process as Exited:
> docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
578bd01b0407 peter/centos-node-hello:latest node /src/index.js 12 minutes ago Exited (143) 9 seconds ago jovial_feynman
So, start it again:
docker start 578bd01b0407
Test, if the process is running:
> docker -ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
578bd01b0407 peter/centos-node-hello:latest node /src/index.js 14 minutes ago Up 2 seconds 0.0.0.0:49160->8080/tcp jovial_feynman
Check the logs:
> docker logs 578bd01b0407
Running on http://localhost:8080
Running on http://localhost:8080
Almost all information about installing docker on MacOS can be found
here.
Install VirtualBox
Download VirtualBox from here.
Double-click the *.dmg file and install the application following the install dialog.
Install boot2docker
boot2docker is used to manage the docker VMs. The installer for MacOS can be found
here. Double-click the
Docker.dmg file and install the application following the install dialog.
> boot2docker init
2014/06/06 09:51:37 Downloading boot2docker ISO image...
2014/06/06 09:51:38 Latest release is v0.9.1
2014/06/06 09:52:01 Success: downloaded https://github.com/boot2docker/boot2docker/releases/download/v0.9.1/boot2docker.iso
to /Users/peterkeller/.boot2docker/boot2docker.iso
Generating public/private rsa key pair.
...
2014/06/06 09:53:03 Creating VM boot2docker-vm...
2014/06/06 09:53:04 Apply interim patch to VM boot2docker-vm (https://www.virtualbox.org/ticket/12748)
2014/06/06 09:53:04 Setting NIC #1 to use NAT network...
2014/06/06 09:53:04 Port forwarding [ssh] tcp://127.0.0.1:2022 --> :22
2014/06/06 09:53:04 Port forwarding [docker] tcp://127.0.0.1:4243 --> :4243
2014/06/06 09:53:04 Setting NIC #2 to use host-only network "vboxnet0"...
2014/06/06 09:53:04 Setting VM storage...
2014/06/06 09:53:10 Done. Type `boot2docker up` to start the VM.
Running the deamon:
> boot2docker up
2014/06/06 09:55:23 Waiting for SSH server to start...
2014/06/06 09:55:47 Started.
2014/06/06 09:55:47 To connect the Docker client to the Docker daemon, please set:
2014/06/06 09:55:47 export DOCKER_HOST=tcp://localhost:4243
Test:
> docker version
Client version: 0.11.1
Client API version: 1.11
Go version (client): go1.2.1
Git commit (client): fb99f99
Server version: 0.11.1
Server API version: 1.11
Git commit (server): fb99f99
Go version (server): go1.2.1
Setup forward network ports. According to the documentation, the boot2docker VM must be powered off for this to work:
> boot2docker stop
Run following script (this takes a while):
for i in{49000..49900}; do
VBoxManage modifyvm "boot2docker-vm" --natpf1 "tcp-port$i,tcp,,$i,,$i";
VBoxManage modifyvm "boot2docker-vm" --natpf1 "udp-port$i,udp,,$i,,$i";
done