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 
2
  • 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. Commented Mar 12, 2022 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: stackoverflow.com/a/36265910/11964524 Commented Jun 1, 2022 at 15:43

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.