building ETL platform Keboola Connection writing about it at 500.keboola.com technologies: // TODO insert cool words here twitter.com/ujovlado ujovlado.com medium.com/@ujovlado 2
start coding After few weeks: OMG, this project needs different version of MySQL and PHP ... Never mind, I'll add or update services and rebuild images 8
run --rm my-app bash Very good for testing docker-compose run --rm my-app ./vendor/bin/phpunit 1. docker-compose up -d 2. run tests 3. docker-compose down 10
debugging Easier than overriding entrypoint Just append what you need to run This is very easy: docker run -i -t --rm debian bash Shouldn't we prepare every service like this? 13
you have containers Don't install tools like travis CLI localy Prepare images and run commands in container to keep your host system clean If you need something, then mount volume Remember that your PC is only a resource 15
-v "/home/vlado/workspace/travis-cli/.travis :/home/`id -un`/.travis" \ -v "$PWD:$PWD" \ -w $PWD \ -u `id -u` \ travis "$@" Magic here is volumes section and $@ which will proxy all passed args to container 17
we mount Docker socket With mounted socket, container has access to Docker on host machine So you can have application running in container and executing commands like docker run in container 21
-q' Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? docker run -i -t \ -v /var/run/docker.sock:/var/run/docker.sock \ docker \ sh -c 'docker ps -q' 5a11cca86782 22
your businness You probably won't get it right (me neither) How would you solve: backups? replication? Probably the best is: buy database as a service (AWS RDS, etc.) have databases server (managed by someone) 25
be the code and environment variables composer install should be run during image build On localhost, it'll load all dependencies from cache Code should be copied in image On localhost override code with volume Test should run in container 26
need your PHP code, it's better to add all these programs to one image. And than only change program to run. Apache: FROM php:7-apache (this can be default service) Cron: RUN apt-get instal cron (to run, override command to cron -f ) PHP CLI: already in Apache image (to run, override command to php some-script.php ) 27
php:7 , not apt-get install php7-cli and similar) For extensions use docker-php-ext-install Do not reinvent a wheel - there's a big community behind of cial images Of cial images are based on Debian - very common and stable distribution Alpine is smaller, but can cause problems (we had one - with memory) 28
but with bigger amount of containers starting/stopping it's almost impossible You probably only need logs, so send them to stdout If you need some les from container, use volume or send them to S3 Run another service with mounted Docker socket to collect these logs Use logspout to forward logs to 3rd party service like Papertrail 29
service (not recommended): docker exec -i -t 5a11cca86782 - it's very dangerous, because executing "wrong" commands can kill whole container If you really need to chcek what's going on - e.g. to be in same environment, just start one container with long running process - e.g. tail -f /xyz . Then docker exec to this container and play. 30