Skip to content

Instantly share code, notes, and snippets.

@thomet
Created January 9, 2015 06:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomet/2f33c6ccd683e702051f to your computer and use it in GitHub Desktop.
Save thomet/2f33c6ccd683e702051f to your computer and use it in GitHub Desktop.
Docker usage examples
* http://docker.com
* guides: https://docs.docker.com/installation/#installation
* Docker hub: http://hub.docker.com
# Useage of existiing images - jira example (all in one)
* docker pull cptactionhank/atlassian-jira:latest # pull the image from docker hub
* docker run -p 8080:8080 cptactionhank/atlassian-jira:latest # run's a container with a jira instance
* http://docker-host:8080/
# Useage of existing images - wordpress example (db and webserver)
* docker pull mysql # pull the image from docker hub
* docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mysecretpassword -d mysql # runs an mysql container
* docker pull wordpress # pull the image from docker hub
* docker run --name some-wordpress --link some-mysql:mysql -e WORDPRESS_DB_PASSWORD=mysecretpassword -d wordpress # run's a container with wordpress instance
* http://docker-host:8080/
# Rails with Docker - on_ruby example
* git clone git@github.com:thomet/on_ruby.git branch: docker
** docker build -t on_ruby . # Builds the on_ruby docker image (see Dockerfile)
** docker pull postgres # pull the image from docker hub
** docker run --name my_db -e POSTGRES_USER=myuser -e POSTGRES_PASSWORD=mysecretpassword -d postgres # run's a container with postgress instance
** docker run --rm --link my_db:db -v ~/thomet-dev/on_ruby:/var/www -e DB_HOST=db -e DB_USERNAME=myuser -e DB_PASSWORD=mysecretpassword on_ruby rake db:setup # run's a container with the rake db:setup command and removes the container afther that
** docker run --name on_ruby --link my_db:db -v ~/thomet-dev/on_ruby:/var/www -e DB_HOST=db -e DB_USERNAME=myuser -e DB_PASSWORD=mysecretpassword -p 5000:5000 on_ruby foreman start # run's a container with on_ruby application
** open http://www.onruby.dev:5000 # don't forgott the www.onruby.dev entry in /etc/hosts in your host system (also leipzig.onruby.dev etc.)
# Tools
* fig: http://www.fig.sh
* install on macos: brew install fig
* in the on_ruby project:
** see fig.yml in project
** fig pull # pulls all images from docker hub
** fig run webserver rake db:setup # runs the rake db:setup for setup the database
** fig up # runs the application and database server
** http://www.onruby.dev:5000
* NSEnter: https://github.com/jpetazzo/nsenter
** how-to use with boot2docker: http://blog.sequenceiq.com/blog/2014/07/05/docker-debug-with-nsenter-on-boot2docker/
** linux: nsenter onruby_webserver_1
** mac: docker-enter onruby_webserver_1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment