Month: January 2022

Learning – Dockerfile

Learning - Dockerfile

This is to refresh my Dockerfile knowledge.

alphine

Create Dockerfile

FROM alphine:3.4
MAINTAINER Mark Takacs mark@takacsmark.com

RUN ark update
RUN ark add vim
RUN apk add curl

Build

docker build -t taka/alpine-smarter:1.0 .

Intermediate images

The Docker intermediate images can speed up the rebuilding process.

docker images -a

To reduce number of intermediate images, update Dockerfile as below

FROM alphine:3.4
MAINTAINER Mark Takacs mark@takacsmark.com

RUN ark update && \
       ark add vim && \
       apk add curl

Clean up dangling image

docker images --filter "dangling=true"
docker rmi $(docker images -q --filter "dangling=true")

python

Dockerfile

  • For normal python
FROM python:3.6.1

RUN pip install numpy
  • For alpine version takes much longer time to build
FROM python:3.6.1-alpine

RUN apk update && apk add build-base
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h

RUN pip install numpy scipy

conda3

  • miniconda3
docker run --rm -ti continuumio/miniconda3 /bin/bash
conda list
conda install numpy
  • anaconda3
docker run --rm -ti continuumio/anaconda3 /bin/bash
conda list

phpslim

Dockerfile

Choose php:7.1.2-apache

Got to https://getcomposer.org, and run installation commands in container

FROM php:7.1.2-apache

RUN ....

COPY ./composer.json /var/www/html/

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

RUN composer install

Map directory

To run docker container with option -v /var/www/html/vendor to indicate using image /var/www/html/vendor folder.

docker run --rm -v $(pwd):/var/www/html/ -v /var/www/html/vendor -p 80:80 takacsmark/phpslim-tut:1.0

As the result, the /var/www/html is mapped to local directory, but /var/www/html/vendor is image directory.

Change DocumentRoot

Add following line into Dockerfile to change the DocumentRoot to /var/www/html/public

RUN set -i 's/DocumentRoot.*$/DocumentRoot \/var\/www\/html\/public/' /etc/apache2/sites-enabled/000-default.conf

Enable default hello message

Create a file /var/www/html/public/.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

Run following command in container to enable module rewrite

a2enmod rewrite

Then add following line in Dockerfile

RUN a2enmod rewrite

Options

COPY

COPY ./config.txt /usr/src/config.txt

ADD

  • Add URL file from internet

  • Add tar file

  • Add compressed file

RUN

EXPOSE

Port

USER

WORKDIR

ARG

LABEL

ENTRYPOINT & CMD

To run command echo Welcome after container created, following configuration can be used.

CMD "Welcome"
ENTRYPOINT echo

The CMD option can be replace using docker run command line, ENTRYPOINT can't. For example, following command will run echo Hello.

docker run echo_image 'Hello'

ENV

References

Dockerfile Tutorial by Example - ( Part I - Basics )
Dockerfile Tutorial by Example - ( Part II - Best practices )
Dockerfile Tutorial by Example - ( Part III - Creating a docker PHP Slim image )

Proxmox Notification Email Error

Proxmox Notification Email Error

Proxmox is using postfix as email software, and the configuration of sender email uses local hostname+domain name as below in /etc/postfix/main.cf

myhostname=full qualified hostname

Issue

The postfix tries to look for email receiver's email server, and send emails directly to the email server using myhostname defined in /etc/postfix/main.cf as senders DNS name. But the server hostname normally isn't using the public valid domain name, which causes email server rejects notification emails.

Fix

Change the default myhostname in /etc/postfix/main.cf to a valid public email domain name.

List zfs Filesystems By Creation Date

List zfs Filesystems By Creation Date

There are many snapshots in Ubuntu system if using zfs as OS filesystem. In order to remove those old snapshots, need to list them by creation date using following command

zfs list -H -t snapshot -o name -S creation

To remove those old snapshots, for example, the oldest 18 snapshots can following command

zfs list -H -t snapshot -o name -S creation | tail -18 | xargs -n 1 zfs destroy

References

How to delete all but last [n] ZFS snapshots?

Disable Windows Defender

Disable Windows Defender

Note: These steps are not effective, the problem is still there.

Disable service

  • Run services.msc
  • Change Startup type to Stop for service Windows Defender Antivirus Service

Disable scheduler

  • Run Task Scheduler
  • Go to Microsoft\Windows\Windows Defender
  • Disable all tasks (4 tasks)

References

How to stop Antimalware Service Executable in Windows 10/11

TrueNAS k3s-server uses more than 10% CPU

TrueNAS k3s-server uses more than 10% CPU

The k3s supposed to be the lightweight k8s, but it used more than 10% when no container running. The problem was reported when TrueNAS running as VM.

This issue also caused high disk utilization, which caused whole system slow, huge IO wait.

Unset Pool

There is a zpool called ix-applications created for k3s. To stop k3s process, needs to unset pool in Apps => Settings => Unset Pool.

Result

After Unset Pool, the CPU utilization dropped from 70% to 5%.

References

k3s-server uses 10% CPU for no reason

Memory test hung after upgrade to 64GB RAM (Follow-up)

Memory test hung after upgrade to 64GB RAM (Follow-up)

Note: This is follow up action of Memory test hung after upgrade to 64GB RAM

This machine was installed TrueNAS, but reboot quite often, about few times a week. After that, I changed it to Proxmox, then one of the active VM kept hanging.

I decided to re-look into the memory test issue.

32GB testing

If only install 32GB memory, the test was OK at beginning. But after full day of testing, start to have 1 failure in one pass, not many but not acceptable.

64GB testing

If install 48GB or 64GB memory, the test caused system hanging in black screen.

Reduce memory speed

After reduce the memory speed to 1066 for 64GB memory, looks OK in Pass 1, but Pass 2 got issue again.

Getting worse

After full day of testing, the test result was getting worse. Previously hung at 80%+, then hung at 40%+. Then looks like problem caused by other factors, such as temperature, etc.

Then I noticed that the power supply is very hot and no noise. Then I think the issue could be the system was not getting enough power.

Change power supply

After take out the power supply, found that power supply fan was not turning. Normally, this issue can not be detected, because the fan towards the bottom of casing.

I got one new power supply, after installed new power supply, the system become colder.

Memory test

After changed the power supply, the memory passed when setting at speed of 1333, which is also the speed detected by motherboard. Even the motherboard auto overclocked CPU speed to 4000+ (CPU speed should be 3600), no error too.

Speed of the old set of RAMs

The new set of RAMs can pass testing at 1600 speed, but the old set got error less than 1 minute.

Although the spec of the old and new RAMs are all the same, brand, speed, etc, but the system detected the new RAMs are 1600, but old set are 1333, no matter in which memory slot. I'm not sure whether the lower speed is caused by aging or because cheated by seller.

Speed of testing among 1600, 1333, and 1066

During the testing, I noticed that the testing speeds are quite different among 1600, 1333 and 1066 if they are under same CPU speed.

References

MemTest86