Docker mistakes

Docker mistakes so you don't have to.

@MrDanack

Press 'c' to toggle code style
Press 's' for speaker notes

Developer time is expensive

Not using docker already.

Docker too slow for yarn/webpack on OSX

Forget Docker networking

 

  • Setup loopback address on host machine
  • Available both from the host and the docker boxes.
  • com.ralphschindler.docker_10254_alias.plist
  • https://gist.github.com/ralphschindler/535dc5916ccbd06f53c1b0ee5a868c93

Not setting WORKDIR


WORKDIR /var/www

Dependencies between containers

Except xdebug enabled

Docker file


FROM php_backend:latest

RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
  --no-install-recommends php7.2-xdebug

COPY xdebug.ini /etc/php/7.2/fpm/conf.d/20-xdebug.ini
xdebug.ini
zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.remote_autostart=1

; Remote connect back doesn't work in docker
; as the incoming request IP doesn't map back
; to the host properly.
xdebug.remote_connect_back=0

; Loopback ftw
xdebug.remote_host=10.254.254.254

One process per container

Boo!! I SAY BOOOOOOO!!!!!

Script Two things at the same time
https://gist.github.com/Danack/15e88f28e2b3504223c06582d5650bcc

Domain names like

local.api.foobar.com

Not

api.local.foobar.com

Config files belong in repo for containers

Really all files in source control - none taken from /etc


/usr/sbin/php-fpm7.2 \
  --fpm-config=/var/www/docker/php_backend/config/php/fpm.conf \
  --daemonize \
  -c /var/www/docker/php_backend/config/php.ini

Supervisord is still rather awesome.

Both Docker and Kubernetes are reinventing the wheel for this tool.

Copy all project files into container

├── src
├── public
├── docker
│   └── php_backend
│       └── Dockerfile
├── docker-compose.yml
        
        volumes:
- .:/var/www
docker build -t load_balancer:latest \
  --file ./docker/php_backend/Dockerfile .

Fin

https://joind.in/talk/c5716