Container's IP Address
- docker inspect CONTAINER-ID | grep IPAddress
Container IP address using docker-compose
- docker-compose ip
Stop and remove all container
- docker stop $(docker ps -a -q)
- docker rm $(docker ps -a -q)
Remove all images
- docker rmi $(docker images -q)
Run bash terminal
- docker-compose run web bash
OR
- docker exec -it CONTAINER-ID /bin/bash
The -t option opens up a terminal, and the -i option makes it interactive. The /bin/bash options opens a bash shell to the running container.
Stops containers and removes containers, networks, volumes, and images created by up.
- docker-compose down [options]
- https://docs.docker.com/compose/reference/down/
Run postgresql container and use psql
- run --name db -d -e POSTGRES_PASSWORD=docker -e POSTGRES_USER=docker postgres
- docker exec -it db psql -U docker postgres #
postgres
is optional
Debugging Rails with pry within a Docker container
docker-compose up -d
&&docker attach web
docker-compose run --service-ports web
docker-compose run
creates a TTY session for your app to connect to, allowing interactive debugging. The defaultdocker-compose up
command does not create a TTY session.
http://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo
- Enter db container
docker exec -it db /bin/bash
- Create database using psql
psql -U postgres create database DATABASE_NAME;
- Copy dump to db container
docker cp DB_DUMP.dump $(docker-compose ps -q db):/
- Restore dump using pg_restore
pg_restore -U postgres --no-owner -d DATABASE_NAME < DB_DUMP.dump
Official doc for using docker without
sudo
in ubuntu:https://docs.docker.com/engine/installation/linux/linux-postinstall/