Skip to content

Instantly share code, notes, and snippets.

@diegopacheco
Last active December 28, 2016 16:11
Show Gist options
  • Save diegopacheco/ac92ffa2ade3eda4c100 to your computer and use it in GitHub Desktop.
Save diegopacheco/ac92ffa2ade3eda4c100 to your computer and use it in GitHub Desktop.
Docker CheatSheet

Build docker image from dockerfile

docker build -t user/container .

Run Container in background and bind all ports

docker run -d -P -t user/container

Run container in same network as host binding port to 8080

docker run -p 8080:8080 -d --net host user/container

Run bash on the container

docker run -it user/container bash

Copy files insde the container to HOST

docker cp mycontainer:/foo.txt foo.txt

Get information(IP, PORTs, etc...) for a specific container

docker inspect user/container

Stop all Containers

docker stop $(docker ps -a -q)

Delete all Untaged Container Images

docker rmi -f $(docker images | grep "<none>" | awk "{print \$3}")

Delete OLD Containers

docker rm `docker ps -aq`

Container Stats

docker stats $CONTAINER_ID $OR_CONTAINER_NAME $ANOTHER_CONAINER_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment