Wednesday, June 29, 2022

linux: debian: ubuntu: How to discover an application and its service to handle it


>PROBLEM

Scenario by example:
On a linux(debian, ubuntu, etc) system you want to discover the postgresql service, its version and how to stop/start.


>SOLUTION


Alternative ways to discover a service:

1. whereis

2. locate

3. ps aux 

Ex.: ps aux | grep postgres

/usr/lib/postgresql/13/bin/postgres -D /var/lib/postgresql/13/main -c config_file=/etc/postgresql/13/main/postgresql.conf

4. systemctl

returns all registerd services


Using systemctl (newer)

systemctl stop ssh

systemctl disable ssh

systemctl enable ssh

systemctl start ssh

systemctl status ssh


Using service

service  postgresql status

service  postgresql start

service  postgresql stop


>ENV

linux/debian

Thursday, June 23, 2022

docker commit lost data

 >PROBLEM

Suppose the following scenario.
 
1. You have create a container mapping to an internal directory.
Example:
docker run -it --name d10n16p11v1 -p 5000:3000 --mount "target=/home/data" d10n16p11:latest /bin/bash

2. Inside the container you created content under /home/data.
For instance:
git clone someURL

After the clone you get a new dir, for instance:
myproject

So you have:
/home/data/myproject

3. Eventually, you decide to preserve the changes and all the stuff (the full state), then you do:

docker commit d10n16p11v1 local/d10n16p11v1

- or using the CONTAINER ID:
docker commit 156e4a967258 local/d10n16p11v1

4. Using the new image, you create a container from it doing:

docker run -it --name d10n16p11v2 -p 5000:3000 --mount "target=/home/data" local/d10n16p11v1 /bin/bash

Accessing the prompt you search for your content:
ls /home/data

but unfortunately, the "myproject" downloaded on the previous container is not there — it is lost!


>SOLUTION

Before exiting the container, copy the content from under the folder that you mapped to create it, in this example is "/home/data" to a system's directory, for instance "/opt".

cp -R /home/data /opt

After, you may commit (step #3).
Next time you run the new container from the committed image, the /opt directory will contain your stuff under data.

IMPORTANT:
Before deleting the previous image or container, test your new image.

>ENV

docker
debian 10

eclipse: java: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" or Exception in thread "main" java.lang.NoClassDefFoundError: org/slf4j/impl/StaticLoggerBinder

  >PROBLEM Using Eclipse, you try to run a simple logging test using "org.slf4j.Logger" like the sample below: package Test; im...