Docker container – Run a container with access to the host’s docker daemon and volumes


docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker/volumes:/var/lib/docker/volumes --mount source=myvol1,target=/vol alpine sh

 

The above command runs a container (alpine image). Inside this container, you have access to the docker daemon of the host as well as the volumes.

Meaning that, from that container, you can manage containers (start, stop, inspect, …)

You can also start new containers with volumes.


apk update && apk add docker

docker run --rm -it --mount source=myvol1,target=/vol alpine sh

 

Advertisements

Netdata in Docker – Monitor my machine

Netdata: https://github.com/netdata/netdata & https://www.netdata.cloud/

is a wonderful tool to monitor a device and trigger alarms

To run it in a second on your local machine, use this docker command

docker run -d --name=netdata -p 19999:19999 -v /proc:/host/proc:ro -v /sys:/host/sys:ro -v /var/run/docker.sock:/var/run/docker.sock:ro --rm --cap-add SYS_PTRACE --security-opt apparmor=unconfined netdata/netdata

Then access the dashboard http://localhost:19999

Linux Mint – Cinnamon – Launch Expo View from command line – Launch Scale (Overview) View

Here is my config

flameshot_2019-01-03_13:14:57

Because I use Workspace grid (2D) and switcher to have my workspaces as a grid, I cannot use the shortcuts to show Expo view and Scale view. (The applet override the shortcuts to navigate through workspaces).

So I added my own custom keyboard shortcuts !

Expo view command

sh -c 'dbus-send --dest=org.Cinnamon --print-reply /org/Cinnamon org.Cinnamon.ShowExpo >/dev/null'

 

Scale view command

sh -c 'dbus-send --dest=org.Cinnamon --print-reply /org/Cinnamon org.Cinnamon.ShowOverview >/dev/null'

 

References:

Apache2.4 – Enable SSL and HTTP to HTTPS redirection

On clean Ubuntu 18.04 installation:

Initial installation: PHP & Apache2


sudo apt-get update

sudo apt-get upgrade

sudo apt-get install php

sudo apt-get install apache2

Enable mod_ssl and mod_rewrite then restart apache


sudo a2enmod ssl

sudo a2enmod rewrite

sudo systemctl restart apache2

Create your site, enable it


sudo nano /etc/apache2/sites-available/my_site.conf

sudo a2ensite my_site

sudo systemctl reload apache2

The content of the site looks like:



  RewriteEngine On
  RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined


  ServerName my_site.pro
  SSLEngine on
  SSLCertificateFile "/etc/ssl/my_site/certificate.crt"
  SSLCertificateKeyFile "/etc/ssl/my_site/private_key.key"

  ServerAdmin info@my_site
  DocumentRoot /var/www/html


 

 

Building angular app with source map fail with “CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory”

I’m building an Angular app with this command:

ng build --prod --configuration=prod --source-map

The versions of Angular and other packages were:

tanguy@tanguy-Aspire-E5-575G:~/Projects/Piximate/web$ ng version

Angular CLI: 6.1.2
Node: 8.10.0
OS: linux x64
Angular: 6.1.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.7.2
@angular-devkit/build-angular 0.7.2
@angular-devkit/build-optimizer 0.7.2
@angular-devkit/build-webpack 0.7.2
@angular-devkit/core 0.7.2
@angular-devkit/schematics 0.7.2
@angular/cdk 6.4.2
@angular/cli 6.1.2
@angular/material 6.4.2
@ngtools/webpack 6.1.2
@schematics/angular 0.7.2
@schematics/update 0.7.2
rxjs 6.2.2
typescript 2.9.2
webpack 4.9.2

There is a Github thread about this issue: https://github.com/angular/angular-cli/issues/5618
But it has never been resolved. However it contains some potential solutions.

What finally worked for me is the solution proposed in this comment: Increase the max size of Node.js for the command by running this:

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod --configuration=staging --source-map

To make my life easier, I created an alias for this command in my package.json

 

// package.json

"scripts": {
  "ng-high-mem": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng",
  "build:prod": "npm run ng-high-mem -- build --prod --configuration=prod --source-map",
  ...
}

Note the double dash “–” before passing the arguments of the build. This is needed to ensure theses arguments are not swallowed by npm run and make sure they are passed to ng-high-mem

So I can build successfully with

npm run build:staging