1

I need to get into interactive mode using docker compose, I have create a Dockerfile just for testing

Dockerfile

FROM ubuntu
CMD ["/bin/bash"]

and used this docker-compose file which contains the two fields tty: true and stdin_open: true

docker-compose

version: "3"
services:
  app:
    container_name: docker-test
    build: .
    image: docker-test
    stdin_open: true 
    tty: true

but when I hit the command sudo docker-compose up it doens't get into interactive mode, and it's the output

[+] Running 1/0
 ✔ Container docker-test  Created                                                                                                                        0.0s 
Attaching to docker-test

I know that there is another solution to do that, by running the container in detached mode and then attach to this container by those commands sudo docker compose up -d and then sudo docker attach <container_name>.

But I wanna know, why the first way doesn't work.

  • what does this have to do with shell or linux? – xpusostomos Apr 30 '23 at 04:49
  • I didn't know the attach workaround, thanks! I also wanna know why the first way doesn't work – kukelia May 06 '23 at 17:12
  • @xpusostomos it involves the terminal so it has to do with shell and linux... – kukelia May 06 '23 at 17:13
  • It probably doesn't work because the stdout of whatever is running in the container goes to the logs. And I'm not sure why you think running it would attach you to its stdin. docker exec -ti XXX /bin/bash is the usual way. – xpusostomos Jun 02 '23 at 07:20

0 Answers0