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
'⚙️백엔드 > Docker' 카테고리의 다른 글
Docker - Docker Engine Failed to Start 해결 방법 (0) | 2024.04.24 |
---|---|
Docker - 컨테이너 시작시 명령어 자동 실행하기 (1) | 2023.10.21 |
Docker - 이미지 파일(.tar)로 저장해서 이미지로 불러오기 (0) | 2023.04.06 |
Docker - 실행중인 컨테이너 포트 바인딩하기 & DNS 서버 주소 설정 (0) | 2023.03.31 |
도커 - 파일 전송하기 (0) | 2022.01.13 |