alpine image error: /bin/sh: can't access tty; job control turned off - linux

I have redis pod with cpec:
spec:
containers:
- name: master
image: xyzwy/redis:7.0
command: ["sh", "-ic"]
args:
- redis-server
- /bin/sh
when I deploy it i get an error in a first line:
***/bin/sh: can't access tty; job control turned off***
1:C 09 May 2022 13:31:44.287 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 09 May 2022 13:31:44.287 # Redis version=7.0.0, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 09 May 2022 13:31:44.287 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
1:M 09 May 2022 13:31:44.288 * monotonic clock: POSIX clock_gettime
1:M 09 May 2022 13:31:44.289 * Running mode=standalone, port=6379.
1:M 09 May 2022 13:31:44.289 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 09 May 2022 13:31:44.290 # Server initialized
1:M 09 May 2022 13:31:44.291 * The AOF directory appendonlydir doesn't exist
1:M 09 May 2022 13:31:44.291 * Ready to accept connections
how can I solve this?

Problem was in
command: ["sh", "-ic"]
-i can not be there, it is not interactive

Related

Redis-server command works inside container but not when docker-compose starts

I have been working on a project to dockerize and automate redis deployments when i stumbled upon a very weird issue with my build. This is my current Dockerfile
ARG BUILD_VERSION=5
FROM redis:${BUILD_VERSION}
RUN mkdir /var/log/redis
RUN chown -R redis:redis /data /var/log/redis
EXPOSE 6379
WORKDIR /usr/local/etc/redis
CMD ["/usr/local/bin/redis-server", "/etc/redis.conf"]
This is my compose:
version: '2.2'
services:
redis:
image: test:red5
restart: unless-stopped
ports:
- "6379:6379"
user: $UID:$GID
volumes:
- /var/lib/redis/:/var/lib/redis/
- /var/log/redis/:/var/log/redis/
- /etc/redis.conf:/etc/redis.conf
to be clear i am mounting the redis dirs and configs as volumes because that is whats on the server.. the UID and GID variable gets called in my .env file.
When i docker exec inside the container and run "/usr/local/bin/redis-server", "/etc/redis.conf" the redis server intializes with no problem. but when i run doocker-compose up i get this exit code.
docker-compose up
Creating network "redis_default" with the default driver
Creating redis_redis_1 ... done
Attaching to redis_redis_1
redis_redis_1 exited with code 0
First question ever on stack overflow :).. Assistance is appreciated
logs(bind address issue was already resolved):
I have no name!#b306768fd72f:/usr/local/src$ tail -f /var/log/redis/redis.log
37:C 19 Jan 2022 18:41:09.928 # Configuration loaded
38:M 19 Jan 2022 18:41:09.931 # Could not create server TCP listening socket *:6379: bind: Address already in use
41:C 19 Jan 2022 18:41:40.389 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
41:C 19 Jan 2022 18:41:40.389 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=41, just started
41:C 19 Jan 2022 18:41:40.389 # Configuration loaded
42:M 19 Jan 2022 18:41:40.393 * Running mode=standalone, port=6379.
42:M 19 Jan 2022 18:41:40.393 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
42:M 19 Jan 2022 18:41:40.393 # Server initialized
42:M 19 Jan 2022 18:41:40.394 * DB loaded from disk: 0.001 seconds
42:M 19 Jan 2022 18:41:40.394 * Ready to accept connections
Found the issue in /etc/redis.conf..
daemonize yes
this was blocking docker from running redis-server properly since it was trying to create a pidfile.. container is now running

While executing Docker command "docker-compose up" getting error - - "node-app-1 | /bin/sh: [npm,: not found"

My docker file
FROM node:alpine
WORKDIR /usr/src/app/
COPY package.json .
RUN npm install
COPY . /usr/src/app/
CMD ["npm" ,"start"]
My docker.yml file
version: '3'
services:
redis-server:
image: 'redis'
node-app:
build: .
ports:
- '8080:8080'
docker-compose output
$ docker-compose up
Container visits-node-app-1 Created
Container visits-redis-server-1 Created
Attaching to visits-node-app-1, visits-redis-server-1
visits-redis-server-1 | 1:C 19 Oct 2021 13:10:09.712 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
visits-redis-server-1 | 1:C 19 Oct 2021 13:10:09.712 # Redis version=6.2.6, bits=64, commit=00000000, modified=0, pid=1, just started
visits-redis-server-1 | 1:C 19 Oct 2021 13:10:09.712 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.713 * monotonic clock: POSIX clock_gettime
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.715 * Running mode=standalone, port=6379.
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.715 # Server initialized
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.715 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.717 * Loading RDB produced by version 6.2.6
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.717 * RDB age 272 seconds
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.717 * RDB memory usage when created 0.77 Mb
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.717 # Done loading RDB, keys loaded: 0, keys expired: 0.
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.717 * DB loaded from disk: 0.000 seconds
visits-redis-server-1 | 1:M 19 Oct 2021 13:10:09.717 * Ready to accept connections
visits-node-app-1 | /bin/sh: [npm,: not found
visits-node-app-1 exited with code 127

Postgresql12.3 wont start on boot, systemd

I installed Postgres 12.3 from source code with steps(according to this):
./configure --with-openssl --with-systemd
make
sudo make install
If I start with pg_ctl from postgres user all works fine:
pg_ctl -D $PGDATA -l /path/to/logfile
Then I try to create a systemd service, as described here.
Steps:
Create file /etc/systemd/system/postgresql.service with content:
[Unit]
Description=PostgreSQL database server
Documentation=man:postgres(1)
[Service]
Type=notify
User=postgres
ExecStart=/usr/local/pgsql/bin/postgres -D /path/to/pgdata
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
[Install]
WantedBy=multi-user.target
sudo systemctl enable postgresql.service
Then I reboot my machine.
After restart Postgres unavaliable. Some logs:
sudo systemctl status postgresql.service
postgresql.service - PostgreSQL database server
Loaded: loaded (/etc/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2020-06-05 03:23:32 MSK; 37s ago
Docs: man:postgres(1)
Process: 724 ExecStart=/usr/local/pgsql/bin/postgres -D /path/to/pgdata (code=exited, status=1/FAILURE)
Main PID: 724 (code=exited, status=1/FAILURE)
Jun 05 03:23:31 ctsvc systemd[1]: Starting PostgreSQL database server...
Jun 05 03:23:32 ctsvc systemd[1]: postgresql.service: Main process exited, code=exited, status=1/FAILURE
Jun 05 03:23:32 ctsvc systemd[1]: Failed to start PostgreSQL database server.
Jun 05 03:23:32 ctsvc systemd[1]: postgresql.service: Unit entered failed state.
Jun 05 03:23:32 ctsvc systemd[1]: postgresql.service: Failed with result 'exit-code'.
journalctl -xe | grep postgres
-- Subject: Unit postgresql.service has begun start-up
-- Unit postgresql.service has begun starting up.
Jun 05 03:23:32 ctsvc postgres[724]: 2020-06-05 03:23:32.209 MSK [724] LOG: starting PostgreSQL 12.3 on armv7l-unknown-linux-gnueabihf, compiled by gcc (Debian 6.3.0-18+deb9u1) 6.3.0 20170516, 32-bit
Jun 05 03:23:32 ctsvc postgres[724]: 2020-06-05 03:23:32.211 MSK [724] LOG: could not bind IPv4 address "172.17.17.42": Cannot assign requested address
Jun 05 03:23:32 ctsvc postgres[724]: 2020-06-05 03:23:32.211 MSK [724] HINT: Is another postmaster already running on port 5432? If not, wait a few seconds and retry.
Jun 05 03:23:32 ctsvc postgres[724]: 2020-06-05 03:23:32.211 MSK [724] WARNING: could not create listen socket for "172.17.17.42"
Jun 05 03:23:32 ctsvc postgres[724]: 2020-06-05 03:23:32.211 MSK [724] FATAL: could not create any TCP/IP sockets
Jun 05 03:23:32 ctsvc postgres[724]: 2020-06-05 03:23:32.212 MSK [724] LOG: database system is shut down
Jun 05 03:23:32 ctsvc systemd[1]: postgresql.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit postgresql.service has failed
-- Unit postgresql.service has failed.
Jun 05 03:23:32 ctsvc systemd[1]: postgresql.service: Unit entered failed state.
Jun 05 03:23:32 ctsvc systemd[1]: postgresql.service: Failed with result 'exit-code'.
Jun 05 03:24:09 ctsvc sudo[1602]: user1 : TTY=pts/0 ; PWD=/home/user1 ; USER=root ; COMMAND=/bin/systemctl status postgresql.service
netstat -tnl | grep "5432" - shows nothing.
After that I can manualy run this service:
sudo systemctl status postgresql.service
● postgresql.service - PostgreSQL database server
Loaded: loaded (/etc/systemd/system/postgresql.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2020-06-05 03:30:57 MSK; 8s ago
Docs: man:postgres(1)
Main PID: 1681 (postgres)
Tasks: 8 (limit: 4915)
CGroup: /system.slice/postgresql.service
├─1681 /usr/local/pgsql/bin/postgres -D /path/to/pgdata
├─1683 postgres: checkpointer
├─1684 postgres: background writer
├─1685 postgres: walwriter
├─1686 postgres: autovacuum launcher
├─1687 postgres: stats collector
├─1688 postgres: logical replication launcher
└─1693 postgres: postgres postgres 172.17.17.40(53600) idle
Jun 05 03:30:56 ctsvc systemd[1]: Starting PostgreSQL database server...
Jun 05 03:30:57 ctsvc postgres[1681]: 2020-06-05 03:30:57.006 MSK [1681] LOG: starting PostgreSQL 12.3 on armv7l-unknown-linux-gnueabihf, compiled b
Jun 05 03:30:57 ctsvc postgres[1681]: 2020-06-05 03:30:57.007 MSK [1681] LOG: listening on IPv4 address "172.17.17.42", port 5432
Jun 05 03:30:57 ctsvc postgres[1681]: 2020-06-05 03:30:57.032 MSK [1681] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
Jun 05 03:30:57 ctsvc postgres[1681]: 2020-06-05 03:30:57.424 MSK [1682] LOG: database system was shut down at 2020-06-05 02:59:03 MSK
Jun 05 03:30:57 ctsvc postgres[1681]: 2020-06-05 03:30:57.725 MSK [1681] LOG: database system is ready to accept connections
Jun 05 03:30:57 ctsvc systemd[1]: Started PostgreSQL database server.
netstat -tnl | grep '5432'
tcp 0 0 172.17.17.42:5432 0.0.0.0:* LISTEN
In my postgresql.conf I have following:
# - Connection Settings -
listen_addresses = '172.17.17.42'
port = 5432
max_connections = 100
If it helps: Postgres runs on Cubietruck with Armbian.
uname -a
Linux ctsvc 4.19.62-sunxi #5.92 SMP Wed Jul 31 22:07:23 CEST 2019 armv7l GNU/Linux
In my system there are no more processes that try to bind this port at boot time. As far as I understand, with the service itself and Postgresql everything is fine. However, something strange happens during the launch, but I can’t understand how to find out the reason of this behavior.
Thanks in advance.
Finally my file /etc/systemd/system/postgresql.service looks like this:
[Unit]
Description=PostgreSQL database server
Documentation=man:postgres(1)
Wants=network-online.target
After=network.target network-online.target
[Service]
Type=notify
User=postgres
ExecStart=/usr/local/pgsql/bin/postgres -D /path/to/pgdata
ExecReload=/bin/kill -HUP $MAINPID
KillMode=mixed
KillSignal=SIGINT
TimeoutSec=0
[Install]
WantedBy=multi-user.target
Thanks to Laurenz Albe comment, I added following in Unit section:
Wants=network-online.target
After=network.target network-online.target
to make sure that network fully operational before PG start. After this PG running correctly after reboot.

Unable to start filebeat.error missing fileld

Below is my filebeat.yml file , I am unable to start service getting error
filebeat.prospectors:
- input_type: log
** paths:**
** - /opt/apache-tomcat-7.0.82/logs/*.log**
document_type: apache-access
fields_under_root: true
output.logstash:
** hosts: '${host}'**
host is environment variable i did export host="10.2.3.1:5044"
Apr 10 06:59:35 node1 filebeat[401]: Exiting: error initializing publisher: missing field accessing 'output.logstash.hosts' (source:'/etc/filebeat/filebeat.yml')
Apr 10 06:59:35 node1 systemd[1]: filebeat.service: main process exited, code=exited, status=1/FAILURE
Apr 10 06:59:35 node1 systemd[1]: Unit filebeat.service entered failed state.
Apr 10 06:59:35 node1 systemd[1]: filebeat.service failed.
Apr 10 06:59:35 node1 systemd[1]: filebeat.service holdoff time over, scheduling restart.
Apr 10 06:59:35 node1 systemd[1]: start request repeated too quickly for filebeat.service
Apr 10 06:59:35 node1 systemd[1]: Failed to start filebeat.
Apr 10 06:59:35 node1 systemd[1]: Unit filebeat.service entered failed state.
Apr 10 06:59:35 node1 systemd[1]: filebeat.service failed.``
I found solution, That's the issue is Systemd does not pass environment variables. I started filebeat as ./filebeat -e -c filebeat.yml it worked for me
By looking at this I see multiple syntax differences to your configuration. There are some examples at the bottom of the page even for hosts.
https://www.elastic.co/guide/en/beats/filebeat/1.2/using-environ-vars.html
Hope it helps.

haproxy error on restarting

HAProxy error on restarting. This is the error i have:
# systemctl status haproxy
● haproxy.service - SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments.
Loaded: loaded (/etc/rc.d/init.d/haproxy; bad; vendor preset: disabled)
Active: failed (Result: exit-code) since Fri 2017-11-03 03:34:04 EDT; 16s ago
Docs: man:systemd-sysv-generator(8)
Process: 6170 ExecStart=/etc/rc.d/init.d/haproxy start (code=exited, status=1/FAILURE)
Nov 03 03:34:04 server systemd[1]: Starting SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments....
Nov 03 03:34:04 server haproxy[6170]: /etc/rc.d/init.d/haproxy: line 26: [: =: unary operator expected
Nov 03 03:34:04 server haproxy[6170]: Starting haproxy: [WARNING] 306/033404 (6178) : config : frontend 'GLOBAL' has no 'bind' directive. Please declare it... intended.
Nov 03 03:34:04 server haproxy[6170]: [ALERT] 306/033404 (6178) : Starting frontend http_front: cannot bind socket [0.0.0.0:80]
Nov 03 03:34:04 server haproxy[6170]: [FAILED]
Nov 03 03:34:04 server systemd[1]: haproxy.service: control process exited, code=exited status=1
Nov 03 03:34:04 server systemd[1]: Failed to start SYSV: HA-Proxy is a TCP/HTTP reverse proxy which is particularly suited for high availability environments..
Nov 03 03:34:04 server systemd[1]: Unit haproxy.service entered failed state.
Nov 03 03:34:04 server systemd[1]: haproxy.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
My configuration file:
haproxy.cfg
Since you are using systemd, you should use systemd unit file instead of the init.d script.
I don't know how you installed haproxy, you can find haproxy.service in haproxy source directory(contrib/systemd), copy it to systemd folder and use it.
cp contrib/systemd_haproxy.service /lib/systemd/system/
systemctl daemon-reload
systemctl enable haproxy
systemctl start haproxy
systemctl status haproxy

Resources