I'm using
CentOS Linux release 8.5.2111
Docker version 23.0.1
Docker Compose version 2.3.4
And my docker compose is insists of images like nginx, was(gunicorn and django), mariadb.
My docker-compose.yml
version: "3.9"
services:
web:
image: python:3.9
hostname: web
container_name: web
restart: always
stdin_open: true
tty: true
depends_on:
- mariadb
build:
context: .
dockerfile: Dockerfile_web
volumes:
- ./facility_iot:/service
- ./tmp:/tmp
# command: sh -c "cd /service && python manage.py runserver 0.0.0.0:8000"
command: sh -c "cd /service && gunicorn --worker-tmp-dir /tmp --bind 0.0.0.0:8000 --timeout=60 config.wsgi:application"
# command: sh -c "cd /service && python manage.py makemigrations && python manage.py migrate"
mariadb:
image: mariadb
hostname: mariadb
container_name: mariadb
cpu_count: 4
restart: always
environment:
MARIADB_ROOT_PASSWORD: [PASSWORD]
TZ: Asia/Seoul
volumes:
- ./mariadb/data:/var/lib/mysql
- ./mariadb/init.sql:/init.sql
ports:
- "3306:3306"
command: --init-file /init.sql
nginx:
image: nginx
hostname: nginx
container_name: nginx
cpu_count: 4
restart: always
depends_on:
- web
- grafana
volumes:
- ./nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
- ./nginx/conf.d/nginx.conf:/etc/nginx/nginx.conf
- ./nginx/static:/static
ports:
- "8000:8000"
grafana:
image: grafana/grafana
hostname: grafana
container_name: grafana
cpu_count: 1
restart: always
depends_on:
- mariadb
volumes:
- ./grafana/conf:/usr/share/grafana/conf
# - ./grafana/data:/var/lib/grafana
My Problem :
I want to get into MariaDB container after I build with
docker compose up --build -d
It works properly with
docker exec -it mariadb /bin/bash
But it has no response when I tried with
docker compose exec mariadb bash
not just mariadb, but everything.
I can get inside of the container, but if i want to do some commands, it just stopped with no response like below.
[root@DST iot-project]# docker compose mariadb bash
root@mariadb:/# ls
[root@DST iot-project]# docker compose mariadb bash
root@mariadb:/# mysql -u root -p
[root@DST iot-project]# docker compose mariadb bash
root@mariadb:/# mysql -u root -p
^C^C^CERRO[0006] got 3 SIGTERM/SIGINTs, forcing shutdown
Really nothing I can do..
My Question :
How can i fix this?
I'm just curious why it is different. (docker exec VS docker compose exec)
I just expected 'docker exec' and 'docker compose exec' works same..
Well, now i found that docker compose V2, v2.3.4 has a problem.
I've re-installed docker several times, but there was always docker compose v2.3.4.
Maybe, in my OS, the most recent version which can be installed is 2.3.4...
So, i moved it to 2.3.3. Then this is finally fixed.
I need to use 2.3.3 until the newer version released...