0

I'm not able to detach from a Docker container after I attached to it.

Dockerfile to define the container:

FROM adoptopenjdk/openjdk16:debian
WORKDIR /app
STOPSIGNAL SIGTERM
RUN apt-get update && apt-get install -y curl && apt clean
CMD curl -so server.jar https://ci.tivy.ca/job/Airplane-1.17/lastSuccessfulBuild/artifact/launcher-airplane.jar && java -jar server.jar

Build the container with: docker build -t minecraft .

docker-compose file:

version: "3.7"
services:
  mc:
    container_name: mc
    ports:
      - 25565:25565
    image: minecraft
    volumes:
      - type: bind
        source: /root/mc
        target: /app

Start the container with: docker-compose up mc

I tryed to attach to console with docker attach mc, it works. But I'm not unable to detach from screen. Ctrl+C not work. Ctrl+P and Ctrl+Q not work. Writing stop (command that will stop the java process) not working

I tryed to attach with docker attach --detach-keys="ctrl-d" mc but is not working

Java process never ends

  • Does this answer your question? [How do you attach and detach from Docker's process?](https://stackoverflow.com/questions/19688314/how-do-you-attach-and-detach-from-dockers-process) – Elikill58 Oct 30 '21 at 10:42

1 Answers1

1

Found fix myself. Need to insert stdin_open and ttyin docker-compose file. New docker-compose.yml:

 version: "3.7"
 services:
  mc:
    container_name: mc
    ports:
      - 25565:25565
    image: minecraft
    volumes:
      - type: bind
        source: /root/mc
        target: /app
    stdin_open: true
    tty: true

Will set this answer as solution in two days because of stackoverflow rules