Linuxkit where is the container running - linux

Linuxkit is very interesting project so started playing with it. I have created image using redis-os.yml example https://raw.githubusercontent.com/linuxkit/linuxkit/master/examples/redis-os.yml
When i boot redis-os it works but i am not seeing any redis server container, i found redis is running but not able to find where.
(ns: getty) linuxkit-f6b2836a15cb:~# pstree
init-+-containerd---7*[{containerd}]
|-containerd-shim-+-tini---rungetty.sh-+-rungetty.sh---login---sh
| | `-rungetty.sh---login---sh---bash--+
| `-11*[{containerd-shim}]
`-containerd-shim-+-redis-server---3*[{redis-server}]
`-11*[{containerd-shim}]
. when i run list container i am not seeing any redis container
(ns: getty) linuxkit-f6b2836a15cb:~# runc list
ID PID STATUS BUNDLE CREATED OWNER
000-dhcpcd 0 stopped /containers/onboot/000-dhcpcd 2022-08-12T21:38:05.40297821Z root
I can see redis listen on port
(ns: getty) linuxkit-f6b2836a15cb:~# netstat -natp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 421/redis-server
tcp 0 0 :::6379 :::* LISTEN 421/redis-server
Question is where is redis container and how do i get to configuration file or exec container filesystem?

I figured out, yes its in namespace but syntax are little complex compare to docker command.
(ns: getty) linuxkit-fa163e26c0e8:~# ctr -n services.linuxkit t exec -t --exec-id bash_1 redis sh
/data # redis-cli
127.0.0.1:6379> PING
PONG
127.0.0.1:6379>

Related

Node Exporter bind address is already running

Node Exporter is always running on my local machine on localhost:9100 even if I don't execute it with terminal following this error message:
FATA[0000] listen tcp :9100: bind: address already in use source="node_exporter.go:172"
By which I can understand that this port number is already being used by another application but the thing is I don't have anything hosted there.
This is what netstat | grep 9100 gives:
tcp 0 0 localhost:60232 localhost:9100 ESTABLISHED
tcp6 0 0 localhost:9100 localhost:60232 ESTABLISHED
All I had to do was to "kill" the 9100 port in which Node Exporter was running by using fuser -k 9100/tcp as this was shown on How to kill a process running on particular port in Linux?.

find port number of IBM MQ Queue Manager

I have created a queue manager using
these commands in a linux machine
crtmqm MQ1
strmqm MQ1
runmqsc MQ1
the queue manager is created successfully,
i wanted to know on which port is the queue manager MQ1 running, i tried all possible ways netstat -au and also ps -ef command. It looks like it is running on a different port. I am unable to find the correct port number where it is running, could anyone help?
By default a new IBM MQ queue manager will not have a listener running on any port.
There is one default LISTENER object on a new queue manager which looks like this:
$echo "dis listener(SYSTEM.DEFAULT.LISTENER.TCP)"|runmqsc MQ1
....
1 : dis listener(SYSTEM.DEFAULT.LISTENER.TCP)
AMQ8630: Display listener information details.
LISTENER(SYSTEM.DEFAULT.LISTENER.TCP) CONTROL(MANUAL)
TRPTYPE(TCP) PORT(0)
IPADDR( ) BACKLOG(0)
DESCR( ) ALTDATE(yyyy-mm-dd)
ALTTIME(hh.mm.ss)
If you were to start this LISTENER the PORT(0) means to start on the default port which is 1414.
Best practice is to not use SYSTEM objects and create a new object such as:
DEFINE LISTENER(LISTENER.1414.TCP) TRPTYPE(TCP) PORT(1414) CONTROL(QMGR)
The CONTROL(QMGR) tells the queue manager to start the listener when the queue manager is started and stop it when the queue manager is ended.
You can manually start and stop the above listener with the commands:
START LISTENER(LISTENER.1414.TCP)
STOP LISTENER(LISTENER.1414.TCP)
Use netstat as root with -p option
sudo netstat -nltp
[sudo] password for root:
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:53 0.0.0.0:* LISTEN 1362/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1580/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1480/cupsd
The last column gives the PID and 'Program name'. If you are running the queue manager with your user, you don't need to sudo.

How to configure Cassandra on GCE then I can access it from my local java application running on Win7?

I created a CentOS on GCE and installed dsc-cassandra 3.0. Then I changed the rpc_address from localhost to the internal ip or external ip in cassandra.yaml.
On the VM, I started cassandra and use cqlsh to access cassandra successfully. But I couldn't use cqlsh internal_ip or cqlsh external_ip.
Also, I turned on tcp:9042 port for this instance.
But I still couldn't access Cassandra from my local java app with the NoHostAvailableException(Cannot connect).
By the way, I did the same thing of my local VM running with VM VistualBox. I could access it.
Running sudo netstat -lntp | grep pid displayed:
tcp 0 0 127.0.0.1:33743 0.0.0.0:* LISTEN 1207/java
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN 1207/java
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN 1207/java
tcp6 0 0 127.0.0.1:9042 :::* LISTEN 1207/java
The Ip address was still 127.0.0.1. I think this is the problem.
How to configure the cassandra.yaml file?
I know where I was wrong.
I used sudo service cassandra restart to restart cassandra after editing the cassandra.yaml. The terminal showed:
Restarting cassandra (via systemctl): [ OK ]
Actually, I think it didn't really restart it. Then I used nodetool stopdaemon to stop cassandra and then start it again. The configuration of cassandra.yaml worked.
Helpful commands:
1.
ps aux | grep cassandra
sudo netstat -lntp | grep <cassandra_pid>
Using these commands to verify the ip/port of the cassandra service on remote VM.
tcp 0 0 127.0.0.1:7000 0.0.0.0:* LISTEN 5928/java
tcp 0 0 127.0.0.1:42682 0.0.0.0:* LISTEN 5928/java
tcp 0 0 127.0.0.1:7199 0.0.0.0:* LISTEN 5928/java
tcp6 0 0 10.138.0.2:9042 :::* LISTEN 5928/java
2.
telnet <cassandra_ip> 9042
Using this command to verify the ip/port of the cassandra service on local machine.

Connecting to a local network Raspberry Pi

I have a:
Rasberry Pi 2
running
Raspbian Jessie Version:November 2015
I am using Undertow (a Java http server) to serve a website. This is the code that I use to build the server.
Undertow server = Undertow.builder()
.addHttpListener(8890, "localhost")
.setHandler(Handlers.pathTemplate()
.add("/", resource(new PathResourceManager(staticFilePath, 100))
.setDirectoryListingEnabled(false))
.build();
Problem: I am unable to see the webserver from another machine on the local network despite being able to ping and SSH into the PI.
What I have done (on the Pi2):
wget localhost:8890
returns the index.html correctly
netstat -lptn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 127.0.0.1:8890 :::* LISTEN 1743/java
Chrome on my development machine 192.168.1.8:8890 gives
ERR_CONNECTION_REFUSED
wget 192.168.1.8:8890
Connecting to 192.168.1.8:8890... failed: Connection refused.
nmap 192.168.1.8
Starting Nmap 6.40 ( http://nmap.org ) at 2015-12-05 14:05 CST
Nmap scan report for 192.168.1.8
Host is up (0.039s latency).
Not shown: 999 closed ports
PORT STATE SERVICE
22/tcp open ssh
Nmap done: 1 IP address (1 host up) scanned in 1.83 seconds
It is my understanding that there is no firewall so I am baffled as to why I can't see the server from my development machine.
See:
tcp6 0 0 127.0.0.1:8890 :::* LISTEN 1743/java
Your web server listens only on localhost address (127.0.0.1). This way it couldn't be accessed from anywhere but localhost.
And your nmap scan shows the same: the only remotely accessible port is 22.
To access this service remotely you have to bind web server to any non-local address belonging to this raspberry pi (192.168.1.8) or to "any address" 0.0.0.0, as SSH service is bound.
How to do this is written in the manual of your web server. Probably, you have to start is with a "-d" param, i.e.
standalone.sh -b=0.0.0.0
standalone.sh -Djboss.bind.address=0.0.0.0
or something like this.
In listener setup code this looks like
"localhost" have to be replaced with some public name. This could be "0.0.0.0" or "192.168.1.8". We also can
cat "192.168.1.8 somename" >> /etc/hosts
and then use somename:
Undertow server = Undertow.builder() .addHttpListener(8890, "somename")

TCP listening socket is not created

I'm developing a Qt application and experience rather weird network issue.
Let me show how it looks from end-user perspective.
First I start up my server and verify that it's listening on a target port:
[user#host server]$ sudo netstat -anp | grep 30004
tcp 0 0 0.0.0.0:30004 0.0.0.0:* LISTEN 11113/./server
Then I connect to the server with telnet:
[user#host server]$ telnet localhost 30004
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
Netstat displays that connection is now established. Nothing fancy so far:
[user#host server]$ sudo netstat -anp | grep 30004
tcp 0 0 0.0.0.0:30004 0.0.0.0:* LISTEN 11113/./server
tcp 0 0 127.0.0.1:30004 127.0.0.1:34608 ESTABLISHED 11113/./server
tcp 0 0 127.0.0.1:34608 127.0.0.1:30004 ESTABLISHED 12657/telnet
Then the server drops the connection based on application-specific timeout. It is set to 10 seconds at the moment:
[user#host server]$ sudo netstat -anp | grep 30004
tcp 0 0 0.0.0.0:30004 0.0.0.0:* LISTEN 11113/./server
tcp 0 0 127.0.0.1:30004 127.0.0.1:34608 TIME_WAIT -
I then shut down the server and verify that the listenning socket is destroyed:
[user#host server]$ sudo netstat -anp | grep 30004
tcp 0 0 127.0.0.1:30004 127.0.0.1:34608 TIME_WAIT -
Finally I start up the server again, but the listening port doesn't show up anymore:
[user#host server]$ sudo netstat -anp | grep 30004
tcp 0 0 127.0.0.1:30004 127.0.0.1:34608 TIME_WAIT -
As a result client cannot connect to the server:
[user#host server]$ telnet localhost 30004
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
What am I doing wrong here? I'm inclined to think that this is a configuration issue, not a bug in the application.
This scenario seems to work on my laptop's Ubuntu. The aforementioned output was produced on linux box as well.
UPDATE: One more thing that is different in these two environemnt is qt version. On my notebook I have 4.8.6, on linux box it's 4.6.2. Not sure if it matters.
Apparently there was an issue with versions of qt libraries. We upgraded it to latest 4.x.x and now the problem seems to be resolved.

Resources