This commit is contained in:
Rico Sta. Cruz 2015-06-21 01:17:06 +08:00
parent d3f127aa71
commit 5a184a75e5
4 changed files with 97 additions and 65 deletions

View File

@ -8,4 +8,5 @@ build: bundle
${bundle} exec jekyll build --safe ${bundle} exec jekyll build --safe
bundle: bundle:
ruby -v
${bundle} ${bundle}

View File

@ -16,7 +16,7 @@ You'll need these:
### Turning on ### Turning on
$ boot2docker up $ boot2docker start
Waiting for VM to be started...... Started. Waiting for VM to be started...... Started.
To connect the Docker client to the Docker daemon, please set: To connect the Docker client to the Docker daemon, please set:

127
docker.md
View File

@ -3,94 +3,99 @@ title: docker
layout: default layout: default
--- ---
Command line interface Manage images
---------------------- -------------
Quick install on a server: Create an `image` from a Dockerfile:
$ curl get.docker.io | sudo sh -x ```yml
docker build [options] .
-t "app/container_name" # name
```
To pull from docker's registry: Run a command in an `image`:
$ docker pull "ubuntu" ```yml
docker run [options] IMAGE
# see `docker create` for options
```
To build from your own `Dockerfile`: Manage containers
-----------------
$ docker build -t "app/container_name" . Create a `container` from an `image`:
To run: ```yml
docker create [options] IMAGE
-a, --attach # attach stdout/err
-i, --interactive # attach stdin (interactive)
-t, --tty # pseudo-tty
--name NAME # name your image
-p, --publish 5000:5000 # port map
--expose 5432 # expose a port to linked containers
-P, --publish-all # publish all ports
--link container:alias # linking
-v, --volume `pwd`:/app # mount (absolute paths needed)
-e, --env NAME=hello # env vars
```
$ docker run "app/container_name" [command and args] ```
-i -t # Interactive mode + pseudo-TTY $ docker create --name app_redis_1 \
-e ENVVAR=value # Environment vars --expose 6379 \
-p 4444 # Expose a port (??) redis:3.0.2
-d # Detached mode ```
$ docker run -t "ubuntu" -i bash Run in a `container`:
OSX Install ```yml
----------- docker exec [options] CONTAINER COMMAND
-d, --detach # run in background
-i, --interactive # stdin
-t, --tty # interactive
```
Prerequisites: ```
$ docker exec app_web_1 tail logs/development.log
$ docker exec -t -i app_web_1 rails c
```
- Install Virtualbox (`brew install virtualbox`) Start/stop a `container`:
- Install Vagrant (http://vagrantup.com)
- Install go (`brew install go`)
Then make the Docker executable (v0.5.1?): ```yml
docker start [options] CONTAINER
-a, --attach # attach stdout/err
-i, --interactive # attach stdin
$ git clone https://github.com/dotcloud/docker.git ~/src/docker docker stop [options] CONTAINER
$ cd ~/src/docker ```
$ make
$ mv ./bin/docker /usr/local/bin/docker
Then run docker: Manage `container`s:
$ cd ~/src/docker
$ vagrant up
```
$ docker ps
$ docker ps -a
$ docker kill $ID
```
Managing Managing
-------- --------
Manage images: Manage `image`s:
# List images ```sh
$ docker images $ docker images
REPOSITORY TAG ID REPOSITORY TAG ID
ubuntu 12.10 b750fe78269d ubuntu 12.10 b750fe78269d
me/myapp latest 7b2431a8d968 me/myapp latest 7b2431a8d968
# Delete an image $ docker images -a # also show intermediate
$ docker rmi b750fe78269d ```
Manage processes: Delete `image`s:
$ docker ps ```yml
$ docker kill $ID docker rmi b750fe78269d
$ docker rmi $ID ```
Manage containers:
Updating containers
-------------------
$ docker commit "app/container_name" -m "Change stuff"
More
----
Start a worker
# Start a very useful long-running process
JOB=$(docker run -d ubuntu /bin/sh -c "while true; do echo Hello world; sleep 1;
done")
# Collect the output of the job so far
docker logs $JOB
# Kill the job
docker kill $JOB
Resources Resources
--------- ---------

26
dockerfile.md Normal file
View File

@ -0,0 +1,26 @@
---
title: Dockerfile
---
### Inheritance
```
FROM ruby:2.2.2
```
### Variables
```
ENV APP_HOME /myapp
RUN mkdir $APP_HOME
```
### Initialization
```
RUN bundle install
```
```
WORKDIR /myapp
```