Docker Foo - Docker Magic Commands

Docker Foo - Docker Magic Commands

Get the IP Address of the docker container:

docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" [container name]

Run a commandline app from the docker container:

docker exec [container name] [command to run]

Attach the current terminal to the docker container terminal:

docker exec -it [container name] [command to run]

eg: attach a terminal

docker exec -it [container name] cmd/terminal

Other docker stuff:

docker ps
docker inspect [container name]

Insert your favorite add here.

Cleaning up after docker

Some good commands to clean up your machine when you run out of space:

# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)