Tech C**P
14 subscribers
161 photos
9 videos
59 files
304 links
مدرس و برنامه نویس پایتون و لینوکس @alirezastack
Download Telegram
Netflix has open sourced his container management system called Titus written in Go Lang. You can see documentation of it here:

- https://netflix.github.io/titus/

Source code and Docs:

- https://github.com/Netflix/titus

#container_orchestration #docker #container #golang #go #netflix #titus #aws
To run grafana in Docker:

docker run -d -p 3000:3000 grafana/grafana


Now if you want to install specific plugins you need to provide the name as an environment variable GF_INSTALL_PLUGINS:

docker run \
-d \
-p 3000:3000 \
--name=grafana \
-e "GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource" \
grafana/grafana


#grafana #docker #plugins
Run newest elasticsearch image on linux using docker:

run -d -p 9200:9200 -v /srv/esdata:/usr/share/elasticsearch/data -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/     elasticsearch/elasticsearch:6.2.4
#docker #es #elasticsearch
Minio is an object storage server that is compatible with Amazon S3. You can run your own object storage server using docker:
- https://docs.minio.io/docs/minio-docker-quickstart-guide

And you can use its Python SDK in order to talk to its endpoint API:
- https://github.com/minio/minio-py

It's usage is very simple and elegant. If you are unfamiliar with object storage read more here:
- https://en.wikipedia.org/wiki/Object_storage

#minio #python #sdk #docker #object_storage
In docker swarm mode you can list nodes with docker node ls. If you want to assign a label to each node you can use the below command to update node labels. For example you can assign a key=value pair like role=storage to one of your node listed with the first command:

docker node update --label-add role=storage YOUR_HOSTNAME

Read more here:
- https://docs.docker.com/engine/swarm/manage-nodes/#update-a-node

The great thing about this labeling is in docker compose file that you can tell docker which server should get deployed on which server (node):

deploy:
replicas: 4
placement:
constraints:
- node.labels.role == storage

NOTE: role is something that we ourselves have been defined. You can define your own as requirements vary.


#docker #node #swarm #label #role
Linux in Docker: Wheezy: "ps: command not found"

Solution:

RUN apt-get update && apt-get install -y procps


#docker #linux #ps #command_not_found #procps
Hello Docker geeks :)

If you run a container and attach to that container you would see its stin, stout or stderr outputs. If you press CTRL+C while you're attached to the container the container will get stopped. In order to detach from the container you can use key sequence CTRL+ p + CTRL+q.

One of the reasons that CTRL+C stops the container is that this key combination sends SIGKILL signal to the container. There is a
parameter called --sig-proxy that is true by default which makes CTRL+C to send SIGINT. You can detach from a container and leave it running using the CTRL-p CTRL-q key sequence.

If you set --sig-proxy to false then CTRL+C would not kill the running container:

docker attach YOUR_CONTAINER_ID --sig-proxy=false

NOTE: you can get container id by issuing docker ps command.

#docker #attach #detach #sig_proxy #sequence_key #SIGINT #SIGKILL
How to start a jetbrains license server on your own host using Docker:

docker run -d -p 8000:80 --name jetbrains-license-server \
-e TZ="Europe/Paris" \
-e JLS_VIRTUAL_HOSTS=jetbrains-license-server.example.com \
-v $(pwd)/data:/data \
crazymax/jetbrains-license-server:latest


There are many env variables you can set as JLS_VIRTUAL_HOSTS above:

TZ : The timezone assigned to the container (default UTC)
JLS_VIRTUAL_HOSTS : Virtual hosts where license server will be available (comma delimited for several hosts)
JLS_CONTEXT : Context path used by the license server (default /)
JLS_ACCESS_CONFIG : JSON file to configure user restrictions (default /data/access-config.json)
JLS_STATS_RECIPIENTS : Reports recipients email addresses for stats (comma delimited)
JLS_REPORT_OUT_OF_LICENSE : Warn about lack of licenses every hour following the percentage threshold (default 0)
JLS_SMTP_SERVER : SMTP server host to use for sending stats (stats disabled if empty)
JLS_SMTP_PORT : SMTP server port (default 25)
JLS_SMTP_USERNAME : SMTP username (auth disabled if empty)
JLS_SMTP_PASSWORD : SMTP password (auth disabled if empty)
JLS_STATS_FROM : From address for stats emails
JLS_STATS_TOKEN : Enables an auth token for the stats API at /reportApi (HTTP POST)

Volumes:
/data : Contains registration data and configuration

Ports:
`80 : Jetbrains License Server HTTP port

Github removes repos related to crack and license, copy or download content from the below link:

- https://github.com/crazy-max/docker-jetbrains-license-server

#docker #license_server #jetbrains #crazymax
DO NOT USE UWSGI multi-threaded mode with alpine image!

I've been stuck on this issue for a couple of days as our service returned 503 Gateway timeout while our server load was totally ok around 1.0 (1m load average). So our load test got failed at the be beginning of the test! We found out it is related to docker base image of python alpine. Use python slim image instead. Or in case you have many changes you can stick with alpine and change thread to 1 in uswgi configuration file.


#docker #alpine #uwsgi #python #slim #respawn
For prometheus you can use an alert manager, it has a docker file in the link below:
- https://hub.docker.com/r/prom/alertmanager

Awesome Prometheus alerts:
- https://github.com/samber/awesome-prometheus-alerts

alertmanager has rules, you can see sample rules here in the following link:
- https://awesome-prometheus-alerts.grep.to/rules

So to add alertmanager service:

alertmanager:
image: prom/alertmanager:latest
restart: always
command: --config.file=/etc/alertmanager/alertmanager.yml
volumes:
- ./alert/config/alertmanager.yml:/etc/alertmanager/alertmanager.yml
dns:
- 8.8.8.8


You alert manager configuration may look something like below:

global:
resolve_timeout: 5m

route:
# When a new group of alerts is created by an incoming alert, wait at
# least 'group_wait' to send the initial notification.
# This way ensures that you get multiple alerts for the same group that start
# firing shortly after another are batched together on the first
# notification.
group_wait: 10s

# When the first notification was sent, wait 'group_interval' to send a betch
# of new alerts that started firing for that group.
group_interval: 5m

# If an alert has successfully been sent, wait 'repeat_interval' to
# resend them.
repeat_interval: 30m

# A default receiver
receiver: "slack"

# All the above attributes are inherited by all child routes and can
# overwritten on each.
routes:
- receiver: "slack"
group_wait: 10s
match_re:
severity: error|warning
continue: true

# - receiver: "sms"
# group_wait: 10s
# match_re:
# severity: error
# continue: true

receivers:
- name: "slack"
slack_configs:
- api_url: 'YOUR-WEBHOOK-URL'
send_resolved: true
channel: 'monitoring'
text: "{{ range .Alerts }}<!channel> {{ .Annotations.summary }}\n{{ .Annotations.description }}\n{{ end }}"

# - name: "sms"
# webhook_config:
# - url: http://a.b.c:8080/send/sms
# send_resolved: true


You should be up & running with this sample configurations.
Spread your love for M2SH :)

#prometheus #prom #alert #alert_manager #docker #dockerfile #slack
How tom remove dangling volumes in docker?

docker volume rm $(docker volume ls -qf dangling=true)


#docker #linux #dangling
In Dockerfile`s some people in the community use `alpine base image in order to reduce docker image size. apk is its package management tool that can be used to install OS packages. So for example if
you want to install network tools (like ping) you need to install netcat-openbsd:

apk add netcat-openbsd


You can squash your image size even further by some tips. When you install a package, linux distros first download the package and put it in a cache folder. In Alpine it is located in /var/cache/apk.
To tell the OS to delete the cache after installation you can provide --no-cache option to it:

apk add --no-cache netcat-openbsd


There are some package like g++ or git that is needed on installation of some other packages. After installation those packages is useless and just increase image size. You can remove those packages b
y using --virtual command:

apk add --no-cache --virtual .build-deps g++ \
&& # do you stuff here \
&& apk del .build-deps


Great job guys! You have reduced your alpine docker images so much :)

#docker #linux #alpine #apk #virtual #no_cache #apk_del #apk_add