728x90
반응형
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 컨테이너에서 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/
https://sonnson.tistory.com/20
728x90
반응형
'⚙️백엔드 > 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 |