Skip to content

Instantly share code, notes, and snippets.

@adixchen
Last active June 20, 2019 13:39
Show Gist options
  • Save adixchen/2182a5527ae4cf0e5b5f5a88ec2c6017 to your computer and use it in GitHub Desktop.
Save adixchen/2182a5527ae4cf0e5b5f5a88ec2c6017 to your computer and use it in GitHub Desktop.
docker and docker-compose usual commands
# docker
## inspect
# - get ip address of the container named "my_container"
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' my_container
$ docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' fb4d0e863eb0 # same but with container_id
## stop
$ docker stop my_container # stop conatainer named "my_container"
$ docker stop $(docker ps -a -q) # stop all running containers
## remove dandling images
### show dandling images
$ docker images -f "dangling=true"
#### remove
$ docker rmi $(docker images -f "dangling=true" -q)
# docker-compose
## file validation
$ docker-compose config #verify validity of docker compose file
$ docker-compose -f PATH_TO_FILE/docker-compose.yml config #verify validity of docker compose file when not executed in directory where file is present
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment