services:
redis:
image: bitnami/redis:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
deploy:
mode: replicated
replicas: 3
ports:
- 6300-6400:6379
$ docker compose up -d
[+] Running 1/4
⠿ Network composetest_default Created 0.0s
⠿ Container composetest-redis-3 Starting 0.1s
⠿ Container composetest-redis-1 Starting 0.1s
⠿ Container composetest-redis-2 Starting 0.1s
Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:6300 -> 0.0.0.0:0: listen tcp 0.0.0.0:6300: bind: address already in use
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
8cb371485fba bitnami/redis:latest "/opt/bitnami/script…" 8 seconds ago Up 7 seconds 0.0.0.0:6300->6379/tcp composetest-redis-3
(도커 20.10.20, compose 2.12.1 기준)
지금 docker compose엔 버그가 있습니다. 포트를 여러개 지정해서 여러 컨테이너를 띄우려고 하면 포트가 겹쳐서 컨테이너가 안뜨는 문제가 있습니다.
단시간에 버그가 수정되진 않을 것 같네요. 이슈가 몇년동안 열려있기도 했고.. 임시방편으로는 그냥 복붙해서 여러개 띄우기밖에 없는듯 하네요
services:
redis-1:
image: bitnami/redis:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6300:6379
redis-2:
image: bitnami/redis:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6301:6379
redis-3:
image: bitnami/redis:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6302:6379
redis-4:
image: bitnami/redis:latest
environment:
- ALLOW_EMPTY_PASSWORD=yes
ports:
- 6303:6379
너무 불편해서.. 시간나면 고쳐보고 싶네요.
Issues
- https://github.com/docker/compose/issues/8530
- https://github.com/docker/compose/issues/7188
반응형
'Infra > docker' 카테고리의 다른 글
[Compose] zookeeper + kafka + kafdrop docker-compose 구성 (0) | 2022.09.01 |
---|---|
[Docker] buildx를 이용한 레이어 캐싱 + Github Actions (0) | 2021.09.04 |
[Docker] 이미지 크기 최적화 (0) | 2021.04.24 |
MacOS docker 자동완성 설정하기 (zsh, oh-my-zsh) (1) | 2020.12.26 |