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
CodePudding user response:
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