Docker

My dockerhub

Docker proxies (Load balancer)

Snippets

See docker containers disk usage

1
docker ps -s

Add debian backports from Dockerfile

1
RUN printf "deb http://httpredir.debian.org/debian jessie-backports main non-free\ndeb-src http://httpredir.debian.org/debian jessie-backports main non-free" > /etc/apt/sources.list.d/backports.list

Synchronize container date as the host date

Just mount two volumes for the /etc/timezone and /etc/localtime

1
2
3
volumes:
- '/etc/timezone:/etc/timezone:ro'
- '/etc/localtime:/etc/localtime:ro'

Inspect stopped image contents

1
2
docker commit CONTAINER NEWIMAGENAME
docker run -ti --entrypoint /bin/bash NEWIMAGENAME

Tools

  • ctop: Top-like interface for container metrics
  • hadolint: Dockerfile linter written in Haskell

Web GUI management

  • Rancher: Complete container management platform
  • portainer: Simple management UI for Docker

Orchestration

  • watchtower - Automatically update running Docker containers

Docker swarm

docker-compose

Override some container environment vars

Just create docker-compose.override.yml and set container overrides like this example:

1
2
3
4
5
6
version: "2"
services:
editor:
environment:
- NODE_ENV=dev

Building image without cache

1
docker-compose build --no-cache service1

Using echo to put contents to file in Dockerfile

Sometimes using RUN echo in your Dockerfile you get an error. To solve just run the echo this way:

1
RUN bash -c 'echo " IdentityFile ~/.ssh/id_rsa" >> /etc/ssh/ssh_config' && \

Using default values overrideable by environment vars

1
${VARIABLE:-default} will evaluate to default if VARIABLE is unset or empty in the environment.

Example:

1
2
ports:
- "${PORT-8080}:80"

Links:

⬆︎TOP