Docker- docker-compose.yml 생성(docker-compose)
docker-compose.yml
version: "3.9"
services:
webserver:
image: search-webserver:2
container_name: webserver
environment:
TZ: Asia/Seoul
ports:
- "22:22"
- "80:80"
dns:
- 8.8.8.8
extra_hosts:
- host.docker.internal:host-gateway
stdin_open: true
tty: true
컨테이너 생성
docker-compose up -d
"exited with code 0 docker"가 뜨면서 컨테이너가 start가 안될 경우 stdin_open: true, tty: true를 추가해야 한다.
참고:
https://lifefun.tistory.com/m/40
docker exited with code 0
[이슈] docker exited with code 0 [원인] 시작 시 bash가 안 붙어서 발생 자신의 컴포즈 설정 파일(*.yml)에서 처리하고자 하는 서비스 영역에 아래 코드를 추가해 주시면 됩니다. stdin_open: true tty: true
lifefun.tistory.com
Docker 컨테이너에서 Host의 localhost에 연결하고 싶을 경우 docker run 할 때 "--add-host=host.docker.internal:host-gateway" 옵션을 추가한다.
docker-compose.yml일 경우에는
extra_hosts:
- host.docker.internal:host-gateway
설정 파일에다 위 내용을 추가한다.
참고:
https://www.devkuma.com/docs/docker/host-localhost-connection/
Docker 컨테이너에서 Host의 localhost 연결
Docker 컨테이너 내부에서 호스트 시스템의 localhost에 서비스를 연결 방법. host.docker.internal
www.devkuma.com
https://sonnson.tistory.com/20
docker-compose에서 localhost 사용
version: "3.0" services: front: image: ... build: ./frontend restart: always ports: - "8501:8501" environment: - REST_API_URL=http://host.docker.internal:8000 extra_hosts: - host.docker.internal:host-gateway docker-compose에서 localhost를 사용하는
sonnson.tistory.com