WEBLOG WEBLOG – My IT experience

Docker image from existing directory tree, chroot or nspawn-container

There is a simple way of building a docker image from scratch using existing chroot or nspawn-container.

Here is what needs to be done:

1. Create a Dockerfile

Read More

CentOS Nagios Dockerfile with a start script

Here is a short Dockerfile that can set up a CentOS + Nagios + Apache instance in few minutes inside a container.

Of course one can always prefer to work with an image instead, however Dockerfiles have proven to be more secure, clear, and easy to change or follow.

Keep in mind to change the version of Nagios to the latest one:

Read More

SuperMicro JBOD ipmitool how to

SuperMicro JBOD’s can be attached through a straight patch cable to its server.

If not set the JBOD, tries to find a DHCP server, if it can’t, it automatically sets as a default address 192.168.1.99.

In order to access and configure the JBOD you need to add an IP address to the interface, to which it is attached, and bring it up:

ip addr add 192.168.1.98/25 dev eno3
  ip l set dev eno3 up
Read More

Centos Docker container su: cannot open session: Permission denied

Issue: After an software update in a Centos 7 docker container `su – user` is no longer possible with the following error

bash-4.2# su - username
Last login: Wed Sep 13 13:20:31 UTC 2017
su: cannot open session: Permission denied

Cause:
Inappropriate settings of nofile in either in

/etc/security/limits.conf

or

/etc/security/limits.d/*.conf

Solution:
There are several solution, which suggest removing nofile unlimited like editing limits.conf and Redhat proposed solution.

However there are also files under /etc/security/limits.d/, where you need to fix nofile references as well. Where you need to change it from unlimited or a number like 500000 to 65536 or less.

bash-4.2# cat /etc/security/limits.d/50-open-files.conf
*         hard    nofile      500000
*         soft    nofile      500000

Need to be edited to become:

bash-4.2# cat /etc/security/limits.d/50-open-files.conf
*         hard    nofile      65536
*         soft    nofile      65536

Docker inspect list ports, volumes and etc.

The `docker inspect` returns useful information about Docker containers.

To filter the returned input one can request a return format.

Main documentation can be found here:
https://docs.docker.com/engine/reference/commandline/inspect/

A peace of information that is not immediately visible, but is always of interest is the list of volumes bonded, which can be extracted as follows:

docker inspect --format='{{json .HostConfig.Binds}}' container_name

To retrieve a list of the binds separated by a new line:

docker inspect --format='{{json .HostConfig.Binds}}' container_name | \
sed 's/"//g;s/\[//g;s/\]//g'| \
tr ',' '\n' 

For the network settings:

docker inspect --format='{{json .NetworkSettings.Ports}}' container_name

To find the command which was used when the docker was started:

docker inspect  -f "{{.Name}} {{.Config.Cmd}}" container_name

To find the environment variables with which the container was started:

docker inspect --format "{{.Config.Env}}" container_name

Many more useful inspect format magics could be found here:

Docker Inspect Template Magic

Categories