1

If I build from the Dockerfile I can run the docker run IMAGE_ID /bin/bash and browse the container.

But if I run docker-compose up -d from docker-compose.yml and run docker attach, it doesn't respond, it stays still in the container terminal and sometimes leaves the container terminal alone

Follow my docker files

Dockerfile

FROM nginx:1.21.6
    
EXPOSE 80

WORKDIR /etc/nginx

ENTRYPOINT /bin/bash

docker-compose.yml

version: "3.8"

services:
  reverse:  
    build:
      dockerfile: Dockerfile
      context: ./nginx/docker 
    image: reverse/nginx
    container_name: reverse
    ports:
      - 80:80
      - 443:443  
    volumes:
      - ./nginx:/etc/nginx
    tty: true 
acran
  • 7,070
  • 1
  • 18
  • 35
Kelvera
  • 15
  • 1
  • 6
  • Why did you change `ENTRYPOINT` for `nginx` image? Run `docker ps -a` to see if it's running or exited. Also change `build:` to `build: .` and add a `dot` after that. – Saeed Mar 12 '22 at 12:55
  • Try `docker-compose run service` instead of `docker-compose up`. `docker-compose up` doesn't work for me even though I specified `stdin_open: true`. See here: https://stackoverflow.com/a/36265910/11964524 – lqi Jun 01 '22 at 15:43

1 Answers1

1

To be able to provide interactive input after attaching you also need to set stdin_open: true in the docker-compose.yml:

services:
  reverse:
    # ...
    tty: true 
    stdin_open: true

But depending on what you want to achieve with this probably a better solution would be

acran
  • 7,070
  • 1
  • 18
  • 35