Home > database >  Docker attach return no feedback
Docker attach return no feedback

Time:01-09

After starting my containers I try to attach it but I get no response; just blinking cursor

I do docker-compose up -d

[ ] Running 2/2
⠿ Container mariadb  Started                                                                                                                                             2.2s
⠿ Container backend  Started   

then docker ps

CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS                  PORTS                              NAMES
85041e7609d4   backend   "docker-php-entrypoi…"   10 seconds ago   Up 7 seconds            0.0.0.0:8000->8000/tcp, 9000/tcp   backend
412c03f5b410   mariadb   "docker-entrypoint.s…"   11 seconds ago   Up Less than a second   0.0.0.0:3306->3306/tcp             mariadb

then docker attach 85041e7609d4

tried docker logs 85041e7609d4 but nothing there

if I docker run -ti --rm backend bash it works but this is not using the docker-compose

version: "3"
services:
 backend:
   container_name: backend
   image: backend
   restart: always
   build: ./docker/backend/
   ports:
     - "8000:8000"
   depends_on:
     - mariadb
 mariadb:
    container_name: mariadb
    restart: always
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: PASSWORD_ROOT
      MYSQL_DATABASE: app
      MYSQL_USER: USER
      MYSQL_PASSWORD: PASSWORD
    expose: ["3306"]
    volumes:
      - "db_data:/var/lib/mysql"
      - "./database_dev.sql:/docker-entrypoint-initdb.d/database_dev.sql"
    ports:
       - "3306:3306"
volumes:
   db_data:

backend image

FROM php:8.1.1-fpm

RUN apt-get clean && apt-get update \
    &&  apt-get install -y --no-install-recommends \
        locales apt-utils git libicu-dev g   libpng-dev libxml2-dev libzip-dev libonig-dev libxslt-dev unzip libpq-dev nodejs npm wget \
        apt-transport-https lsb-release ca-certificates

RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen  \
    &&  echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen \
    &&  locale-gen

RUN curl -sS https://getcomposer.org/installer | php -- \
    &&  mv composer.phar /usr/local/bin/composer

RUN curl -sS https://get.symfony.com/cli/installer | bash \
    &&  mv /root/.symfony/bin/symfony /usr/local/bin

RUN docker-php-ext-configure \
            intl \
    &&  docker-php-ext-install \
            pdo pdo_mysql pdo_pgsql opcache intl zip calendar dom mbstring gd xsl

RUN pecl install apcu && docker-php-ext-enable apcu

RUN npm install --global yarn

CMD tail -f /dev/null

WORKDIR /var/www/app/

CodePudding user response:

You've attached to a container running

tail -f /dev/null

This command has no output and accepts no input. Nothing will ever come out of /dev/null.

If you need a shell, you should exec that shell, e.g.

docker-compose exec backend bash

And if you want logs, the command you run should be your app, and your app should output logs.

  •  Tags:  
  • Related