Prefix with sudo if the current user is not root (admin) ~ applicable to Linux environment.
General
1 | docker version ~ display version |
Stats
Along with the linux memory usage command ~ sudo free -m you can also check each containers stats:
1 | sudo docker stats [CONTAINER NAME] |
Copy
Copy from the logs dir to the host
1 | sudo docker cp [CONTAINER NAME]:/app/logs/ /home/carl/obfuscation/ |
Copy to container
1 | sudo docker cp /path/on/host [CONTAINER NAME]:/path/on/container |
EXEC session to container
1 | sudo docker exec -it 279 sh (where 279 is the start of the container ID) |
then you can PING [CONTAINER NAME] (note the container you ping needs to be on the same bridge, example golden-gate)
CRTL C ~ quit ping
CTRL PQ ~ quit EXEC session
Also see access-postgresql-database-command-line-terminal-in-a-container
For bash run
- sudo docker exec -it [CONTAINER-NAME] /bin/bash
1 | sudo docker exec compose-angular-web cat /etc/nginx/nginx.conf |
Interactive processes (like a shell)
This was helpful when debugging pgDash when the container would not start and we needed to run in interactive mode, run from bash their command to start the app and then cat out the logs.
1 | docker run -it –entrypoint /bin/bash pgdash_image (note the – – before entrypoint) |
<* https://docs.docker.com/engine/reference/run/#operator-exclusive-options>
Network
1 | sudo docker network connect golden-gate [CONTAINER NAME] |
Inspect
1 | docker network inspect [NETWORK NAME] |
Volumes
1 | docker volume ls |
Options
Options are passed after commands, I can never rememeber what they all do :)
1 | -t ~ Name and optionally a tag in the ‘name:tag’ format |