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

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

Related

Docker compose command fails as root user

I'm having a hard time figuring out what's wrong.
when I run docker-compose -f ./docker-compose.yml build parallel I get this output, saying that docker isn't running (which isn't true, see below)
joel#ogofe:/home/dev/udagram$ docker-compose -f ./docker-compose.yml build parallel
/home/joel/.local/lib/python3.9/site-packages/requests/__init__.py:109: RequestsDependencyWarning: urllib3 (1.26.9) or chardet (5.0.0)/charset_normalizer (2.0.6) doesn't match a supported version!
warnings.warn(
ERROR: Couldn't connect to Docker daemon at http://172.17.0.0:2375 - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
I've checked the status of the docker service, and it's up and running. I even tried restarting it to no avail.
Also worth knowing: I've scoured Stack Overflow for a fix, but haven't found one yet. I did get a nudge in the right direction (I hope) suggesting that it's a permission issue (ie docker-compose can't see the running service because it was started by the root user)
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2022-09-01 06:36:18 WAT; 2h 45min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 15087 (dockerd)
Tasks: 159
Memory: 34.2M
CPU: 5.999s
CGroup: /system.slice/docker.service
└─15087 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Sep 01 06:35:46 ogofe dockerd[15087]: time="2022-09-01T06:35:46.555705337+01:00" level=info msg="ccResolverWrapper: sending update to cc: {[{unix:///run/containerd/cont>
Sep 01 06:35:46 ogofe dockerd[15087]: time="2022-09-01T06:35:46.555733870+01:00" level=info msg="ClientConn switching balancer to \"pick_first\"" module=grpc
Sep 01 06:35:49 ogofe dockerd[15087]: time="2022-09-01T06:35:49.830692206+01:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
Sep 01 06:36:07 ogofe dockerd[15087]: time="2022-09-01T06:36:07.519863155+01:00" level=info msg="Loading containers: start."
Sep 01 06:36:15 ogofe dockerd[15087]: time="2022-09-01T06:36:15.201916110+01:00" level=info msg="Default bridge (docker0) is assigned with an IP address 172.17.0.0/16. >
Sep 01 06:36:15 ogofe dockerd[15087]: time="2022-09-01T06:36:15.796809326+01:00" level=info msg="Loading containers: done."
Sep 01 06:36:17 ogofe dockerd[15087]: time="2022-09-01T06:36:17.811988794+01:00" level=info msg="Docker daemon" commit=363e9a8 graphdriver(s)=overlay2 version=20.10.5
Sep 01 06:36:18 ogofe dockerd[15087]: time="2022-09-01T06:36:18.465597339+01:00" level=info msg="Daemon has completed initialization"
Sep 01 06:36:18 ogofe systemd[1]: Started Docker Application Container Engine.
Sep 01 06:36:18 ogofe dockerd[15087]: time="2022-09-01T06:36:18.893028725+01:00" level=info msg="API listen on /run/docker.sock"
However, running sudo docker-compose ... doesn't seem to work either, and I'm greeted with a new error. I am at a loss here, and I'm running out of time to submit this project.
joel#ogofe:/home/dev/udagram$ sudo docker-compose -f ./docker-compose.yml build parallel
Traceback (most recent call last):
File "/usr/local/bin/docker-compose", line 5, in <module>
from compose.cli.main import main
ModuleNotFoundError: No module named 'compose'
I know my writing could use a lot of work, but I hope this is at least clear enough for someone to understand my challenge.
Thank You for the help. Cheers!
PS: I'm running on a Kali Linux distro, and I have docker-desktop installed.
I was able to get it working.
First I had to reinstall docker-compose by running curl -L https://raw.githubusercontent.com/docker/compose-cli/main/scripts/install/install_linux.sh | sh
I noticed that running sudo docker-compose was the wrong format of the command, instead I used sudo docker compose -f ./docker-compose-build.yml build --parallel and it worked fine.
Thanks #DavidMaze for your help.

RHEL7 docker-compose will not work "transport: Error while dialing unable to upgrade to h2c, received 404"

Looking to fix this issue. I'm running RHEL7 with docker-compose 2.9.0. I've boiled things down to these files:
[<user>]$ ls -la
-rw-rw-r--. 1 glaisne glaisne 166 Aug 4 14:22 docker-compose.cloud-build.yml
-rw-rw-r--. 1 glaisne glaisne 76 Aug 4 14:04 .env.azure
drwxrwxr-x. 2 glaisne glaisne 24 Aug 4 14:12 helloWorld
[<user>]$ ls ./helloWorld
Dockerfile
[<user>]$ cat ./docker-compose.cloud-build.yml
version: '3.4'
services:
hello-world:
image: ${AZURE_DOCKER_REGISTRY}<servername>.hello-world:${DOCKER_IMAGE_TAG}
build:
context: ./helloWorld
[<user>]$ cat .env.azure
AZURE_DOCKER_REGISTRY=<server>.azurecr.io/
DOCKER_IMAGE_TAG=dev
[<user>]$ cat ./helloWorld/Dockerfile
FROM alpine
CMD ["echo", "Hello World"]
If I run
sudo docker-compose -f ./docker-compose.cloud-build.yml --env-file=./.env.azure build
I get this error:
[+] Building 0.0s (0/0)
listing workers for Build: failed to list workers: Unavailable: connection error: desc = "transport: Error while dialing unable to upgrade to h2c, received 404"
I am no Linux or docker guru, but I've done about all I can to fix this with no luck. The Docker service is running on the system (Docker version info below). Any insight on what this could be would be helpful. I've rebooted, Docker service has been given enough time to run, I don't see any network/firewall issues that I can tell ( from 404 ). I've even looked at the source (I don't speak go), and can't fine any reference to 'dial', 'h2c', 'workers.'
TIA
Docker version info:
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-209.git7d71120.el7_9.x86_64
Go version: go1.10.3
Git commit: 7d71120/1.13.1
Built: Fri Jan 7 13:15:46 2022
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-209.git7d71120.el7_9.x86_64
Go version: go1.10.3
Git commit: 7d71120/1.13.1
Built: Fri Jan 7 13:15:46 2022
OS/Arch: linux/amd64
Experimental: false
It seems that this problem has not yet been completely solved, but for the moment this may help you, try to set DOCKER_BUILDKIT=0 env var to disable the use of the buildkit API.
Reference: https://github.com/containers/podman/issues/13889
Note: If you use the sudo command for execute docker-compose please use the -E flag for preserve the env variables.

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

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

pgadmin4 can't connect to postgres running over Rocky Linux

The postgres is running on Rocky Linux 8.5:
sudo systemctl status postgresql-14
● postgresql-14.service - PostgreSQL 14 database server
Loaded: loaded (/usr/lib/systemd/system/postgresql-14.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/postgresql-14.service.d
└─override.conf
Active: active (running) since Thu 2022-03-10 04:31:09 GMT; 16min ago
Docs: https://www.postgresql.org/docs/14/static/
Process: 67527 ExecStartPre=/usr/pgsql-14/bin/postgresql-14-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
Main PID: 67534 (postmaster)
Tasks: 8 (limit: 101066)
Memory: 18.3M
CGroup: /system.slice/postgresql-14.service
├─67534 /usr/pgsql-14/bin/postmaster -D /mnt/data/db-rocky-primary/data
├─67536 postgres: logger
├─67538 postgres: checkpointer
├─67539 postgres: background writer
├─67540 postgres: walwriter
├─67541 postgres: autovacuum launcher
├─67542 postgres: stats collector
└─67543 postgres: logical replication launcher
Mar 10 04:31:08 db-primary-rocky systemd[1]: Starting PostgreSQL 14 database server...
Mar 10 04:31:09 db-primary-rocky postmaster[67534]: 2022-03-10 04:31:09.590 GMT [67534] LOG: redirecting log output to logging collector process
Mar 10 04:31:09 db-primary-rocky postmaster[67534]: 2022-03-10 04:31:09.590 GMT [67534] HINT: Future log output will appear in directory "log".
Mar 10 04:31:09 db-primary-rocky systemd[1]: Started PostgreSQL 14 database server.
I can connect to it with no issues when on the box:
psql
psql (14.2)
Type "help" for help.
postgres=# \conninfo
You are connected to database "postgres" as user "postgres" via socket in "/var/run/postgresql" at port "5432".
I have added this to the pg_hba.conf file:
host all all 192.168.1.0/24 trust
I have also changed the following in the postgresql.conf file and restarted the server:
listen_addresses = '*'
why I can't connect to it via pgadmin4? I am sitting in the 192.168.1.0/24 network and the PostgreSQL running in 192.168.1.0/24 network.
Both networks can ping each other. The pgadmin4 gives connection refused error. I am not sure why?
what am I missing?
thanks
As per #Nic3500 comment, that's how I fixed it:
check if postgres is listening on the designated port:
sudo netstat -nltp
Now check if firewall is enabled:
systemctl status firewalld
OR
sudo firewall-cmd --state
if the service is active and running then simply do the following:
sudo firewall-cmd --add-service=postgresql
Make the settings permanent:
sudo firewall-cmd --runtime-to-permanent
Now you can connect with no issues

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

Resources