sumitasok
3/31/2015 - 6:42 AM

Docker shell commands

Docker shell commands

docker build -t pandas_app:latest .
# Link a mysql container and create a server container
docker run -it --link mysql-custom1:alias --name custom-server-container-name -p 7000:7000 server-image:serverip50 bash
# A quick way to recover space (assuming site is running)

docker rm `docker ps -a | grep Exited | awk '{print $1 }'`
docker rmi `docker images -aq`

# To remove all containers
docker rm -f $(docker ps -aq)

# to get mysql
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=mice -d mysql
docker run -it --link db:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

docker run -it --link db:mysql --rm ark-server sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'
# getting-a-docker-containers-ip-address-from-the-host
# http://stackoverflow.com/questions/17157721/getting-a-docker-containers-ip-address-from-the-host

CID=$(docker run -d -p 4321 base nc -lk 4321);
docker inspect $CID

docker inspect --format '{{ .NetworkSettings.IPAddress }}' $CID