Skip to content

Instantly share code, notes, and snippets.

@lalitkale
Last active July 3, 2018 09:50
Show Gist options
  • Save lalitkale/76cf8c8b8f07570f9e94ca19f88d9719 to your computer and use it in GitHub Desktop.
Save lalitkale/76cf8c8b8f07570f9e94ca19f88d9719 to your computer and use it in GitHub Desktop.
Docker Useful Commands for Debugging containers

Login inside the container/bash into container/get inside the container []=you need to replace it with your own container/image parameter

docker run -dit [image_name]

By ID

docker exec -i -t 665b4a1e17b6 /bin/bash

By Name

docker exec -i -t loving_heisenberg /bin/bash

copy file to and from container

docker cp

e.g. modify sonar-scanner.properties file to point it to sonarqube server container

docker cp stupefied_hermann:/sonar-scanner/sonar-scanner-3.1.0.1141/conf/sonar-scanner.properties . docker cp sonar-scanner.properties stupefied_hermann:/opt/sonar-scanner/sonar-scanner-3.1.0.1141/conf/sonar-scanner.properties

copy directory content to /app directory in container

docker cp . [cotainername]:/app/

diagnostic EntryPoint while building the image from scratch. This is helpful so that you can bash into container and see what's going on inside

ENTRYPOINT ["tail", "-f", "/dev/null"]

OR

ENTRYPOINT ["cat"]

Remove Dangling images

docker rmi $(docker images --quiet --filter "dangling=true")

Remove Inactive containers

docker rm -f $(docker ps -a -q)

check the disk usage of all docker images

docker system df -v

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment