fe2739895568e191e7e1c2434df18665e3e19871
compute/docker.md
| ... | ... | @@ -30,13 +30,24 @@ git config --global core.sshCommand 'ssh -o StrictHostKeyChecking=no' |
| 30 | 30 | If you're worried about MITM attacks, add the host pubkeys to /var/tmp/user/.ssh/known_hosts in your Dockerfile instead. |
| 31 | 31 | And if you're _really_ worried about MITM attacks, stop reading random wikis you found on the internet looking for ssh/git advice, and hire someone who knows what they're doing you moron. |
| 32 | 32 | |
| 33 | +## python |
|
| 34 | +Python stdout is buffered to non-tty file handles, so watching 'docker logs -f' will be a waste of everyone's time. Switch off buffering in your wrapper script with: |
|
| 35 | +``` |
|
| 36 | +export PYTHONUNBUFFERED=1 |
|
| 37 | +/app/blah.py |
|
| 38 | +``` |
|
| 39 | + |
|
| 33 | 40 | # Debug |
| 34 | 41 | ## Processes |
| 35 | 42 | Find docker processes from system shell |
| 36 | -`# docker ps` |
|
| 37 | -`# ps -eo pid,cgroup,cmd | grep <first 8 chars of containerID>` |
|
| 43 | +``` |
|
| 44 | +# docker ps |
|
| 45 | +# ps -eo pid,cgroup,cmd | grep <first 8 chars of containerID> |
|
| 46 | +``` |
|
| 38 | 47 | |
| 39 | 48 | ## Network |
| 40 | 49 | Look at the network config from a container's namespace |
| 41 | -`# nsenter -t $(docker inspect --format '{{.State.Pid}}' <containerid>) -n ip {addr|route|...}` |
|
| 50 | +``` |
|
| 51 | +# nsenter -t $(docker inspect --format '{{.State.Pid}}' <containerid>) -n ip {addr|route|...} |
|
| 52 | +``` |
|
| 42 | 53 | or run bash instead of ip to get a shell in the namespace. |
| ... | ... | \ No newline at end of file |