Docker

My dockerhub

Docker proxies (Load balancer)

Storage

  • rexray - REX-Ray is a container storage orchestration engine enabling persistence for cloud native workloads http://rexray.io

Tools

Web GUI management

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

Security

  • dockerrootplease - Gives you root on the hostOS, if you’re a member of the ‘docker’ group.

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'

Debugging inside container

Add those lines to your docker-compose.yml file

1
2
3
app:
tty: true
stdin_open: true

The you can enter to session running docker attach project_app_1

Source

Inspect stopped image contents

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

Orchestration

  • watchtower - Automatically update running Docker containers
  • docker-autoheal - Monitor and restart unhealthy docker containers.

Docker swarm

Convert build args to environment variables

1
2
ARG buildtime_variable=default_value
ENV env_var_name=$buildtime_variable

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:

Docker with cronjob

Comments

⬆︎TOP