Easy Docker

Docker
This talk was given at the LA Django meetup in DTLA on 6/19/2018. My thanks to Anthony at Gridspace for sponsoring! Also thanks to Marcel for inviting me again.This page is http://bit.ly/jta-easy-dockerThe slides are in Googledocs, source code is in Github => https://github.com/johntellsall/easy-docker
Read More

TIP: use Strace to debug issues inside Docker

Dev, Docker, Testing
Yesterday my Docker application wasn't working correctly -- the appserver is hanging.  Debugging this is a challenge: there's no crash nor stack trace to point out the issue.  Is the appserver misconfigured, so it's trying to talk to a non-existent database? Is the config okay, but the network is not set up correctly?  Can an external service not see our Docker container correctly?To debug this I used my good old "strace" command to trace exactly what is happening. It outputs log messages for all system calls the appserver does, including all the network I/O.  Alas it didn't work for me:strace: test_ptrace_setoptions_for_all: PTRACE_TRACEME doesn't work: Operation not permittedThis is odd, as the Docker container is running with root permissions, and the parent container is Debian.My buddy Loren says this is a…
Read More

TIP: work with Amazon AWS ECS Container Service Docker containers

Dev, Docker
When running Amazon EC2 Container Service (ECS), have these two commands running in Tmux on your instances:tail -f $(ls -1t /var/log/ecs/ecs-agent.log.* | head -1)sudo tail -f /var/log/upstart/docker.logIn another Tmux tab, this command lets you look at the logs from your running Docker container:docker logs -f $(docker ps --filter name=myname,status=running --quiet)
Read More

TIP: fix bizarre Docker problems

Docker, Testing
docker rm -fv $(docker ps -aq)Sometimes testing produces strange Docker-related problems.  The above command kills all containers, including the stopped ones.  The "-v" also destroys each container's private storage volumes.  This is great because Docker likes to run differently different times you run it -- because it has local state.  Local state is evil!  Run the above command every now and then so Docker starts from a clean, state-less, state.In Docker, stopping a container is different from killing it.  The former stops the running container/process, but leaves the private volume.  The latter zaps the volume.Thanks Sam!
Read More

TIP: find specific Docker container without using "cut" or other Shell silliness

Docker
People on the Interwebs love doing things in a leaden, verbose, laborious, and dusty manner.  Like piping a command through egrep then cut and sed then awk, when just "awk" will do.Take Docker. We often want to find out which container is running something specific. Once we find our container, we want to "exec" a shell into it, or we want to kill it.Here's the best way that doesn't mess with cut/sed/awk:$ docker ps --filter ancestor=web,status=running --quiet8fbc117716c3In the previous command I was looking for the container ID that is descended from my "web" image. I'm not interested in my database nor Redis nor anything else, I want my web container.Here's how to use it in practice, by killing the web container:$ docker rm -f $(docker ps --filter ancestor=web,status=running --quiet)8fbc117716c3Also, here's…
Read More