Skip to content

Instantly share code, notes, and snippets.

@tokhi
Last active December 28, 2016 19:35
Show Gist options
  • Save tokhi/ef735a5e88383e556e8b to your computer and use it in GitHub Desktop.
Save tokhi/ef735a5e88383e556e8b to your computer and use it in GitHub Desktop.
# install docker toolbox
# create docker machine:
#docker-machine create --driver virtualbox default
eval "$(docker-machine env default)"
# check the version
docker version
docker-compose build
docker-compose up
# nginx installation
docker run -d -p 80:80 nginx
curl $(docker-machine ip default):80
echo "******\n"
docker ps
echo "******\n"
# docker-machine env info:
docker-machine env default
# remove docker machine:
docker-machine rm default
# compose run app ls
# https://blog.codeship.com/running-rails-development-environment-docker/
# connect to container bash
docker exec -it wordpress bash
# install package in debian docker
apt-get -qq update
apt-get -qq install vim -y
# run the container on a specific ip and port
docker run --name wordpress -p 192.168.99.100:80:80 -v /volume-wordpress -e WORDPRESS_DB_HOST=172.16.100.47:3306 \
-e WORDPRESS_DB_USER=wordpress -e WORDPRESS_DB_PASSWORD=wordpress -d wordpress
# expose app environment variables
docker-compose run myapp env
# run the container with port forwarding
docker run -d -p 9200:9200 elasticsearch
# link the container to another container ( e.g; link kibana to elastic search)
docker run --link adoring_nobel:elasticsearch -p 5601:5601 kibana
#list all the containers with their ips:
docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(docker ps -aq)
# ping the container ip
docker run -it elasticsearch ping 172.17.0.2
# inspect a container:
docker inspect elasticsearch
## FAQ ###
#* Network timeout error?
docker-machine restart default
eval "$(docker-machine env default)"
#* Problem with port forwarding? (make sure you are using the stable version.)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment