Skip to content

Instantly share code, notes, and snippets.

@mikemadisonweb
Last active March 15, 2017 10:04
Show Gist options
  • Save mikemadisonweb/2443f8fcb1775af3ad076b6a56148f1b to your computer and use it in GitHub Desktop.
Save mikemadisonweb/2443f8fcb1775af3ad076b6a56148f1b to your computer and use it in GitHub Desktop.
in docker-compose.yml:
nginx:
restart: always
build: ./nginx/
ports:
- "80:80"
extra_hosts:
# requires `export DOCKERHOST="$(ifconfig en0 inet | grep "inet " | awk -F'[: ]+' '{ print $2 }')"` in ~/.bash_profile
- "dockerhost:$DOCKERHOST"
in ~/.bash_profile:
# see https://github.com/docker/docker/issues/1143
export DOCKERHOST="$(ifconfig en0 inet | grep "inet " | awk -F'[: ]+' '{ print $2 }')"
in nginx-conf:
location / {
proxy_pass http://dockerhost:3000;
proxy_set_header host $host;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
}
# bash commands
docker-compose exec php bash
# Composer (e.g. composer update)
docker-compose exec php composer update
# Removes stopped service containers with anonymuous volumes
docker-compose rm -v
# Retrieve an IP Address (here for the nginx container)
docker inspect $(docker ps -f name=nginx -q) | grep IPAddress
# MySQL commands
docker-compose exec db mysql -uroot -p"root"
# Check CPU consumption
docker stats $(docker inspect -f "{{ .Name }}" $(docker ps -q))
# Delete all containers
docker rm $(docker ps -aq)
# Delete all images
docker rmi $(docker images -q)
# Stop all docker containers
docker stop $(docker ps -a -q)
# Remove all docker volumes
docker volume ls -qf dangling=true | xargs -r docker volume rm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment