My problem situation
1. I want to run the Backend service with the docker
1.1 Docker1.2. The Backend service runs Flask on 5000 ports.2.1 Vscode runs Flask on the docker container with debugger and operates on port 5000.
2.2 Port 5000 used when the docker was running and 5000 used as debugging inside the docker container collide because it is the same.2.3 However, if you use another port such as 5005 as the port used when the docker started the service, 5005 (for docker execution), The Flask runs twice with 5000 (for debugging) and uses an unnecessary process.
Solution
When the docker service is run, the
tail-f/dev/null
Continue reading the last end of the tail-f file. /dev/null Create an infinite loop by continuing to read the non-existent space in Linux.
So you can keep the process running without shutting it down.
docker> command를 이용하는 경우
docker run --entrypoint "tail -f /dev/null"
Dockerfile을 이용하여 이미지를 빌드하는 경우
# project/Dockerfile
FROM dockerimage:dockerimageversion
CMD tail -f /dev/null
docker-compose.yml파일을 이용하여 컨테이너를 실행하는 경우
# project/docker-compose.yml
version: "X"
services:
service_name:
container_name: container_name
image: docker_image
volumes:
- - ./:/app/
working_dir: /app/
command: tail -f /dev/null
Can't I just erase the docker's command command itself?
Docker containers are designed to run the entrypoint command when they run in detached(-d option) mode, and then shut down immediately in
foreground (opposite concept of background).
If the server or service inside the container stops, the container may also be terminated even if the user does not want it.
→ that is, as soon as the service is turned on, there is no running process and it is turned off immediately.
How to maintain the docker container execution and/dev/null description