#!/bin/bash
# docker-compose.yaml 파일 생성
echo "version: '3'" > docker-compose.yaml
echo "services:" >> docker-compose.yaml
# macvlan 네트워크 설정
echo "networks:" >> docker-compose.yaml
echo " macvlan:" >> docker-compose.yaml
echo " driver: macvlan" >> docker-compose.yaml
echo " driver_opts:" >> docker-compose.yaml
echo " parent: eth0" >> docker-compose.yaml # 호스트에서 사용 중인 네트워크 인터페이스 이름으로 변경
# 1부터 100까지의 컨테이너에 대한 설정을 파일에 추가
for i in {1..100}
do
MAC_ADDRESS=$(printf "12:34:56:78:90:%02x" $i) # MAC 주소 생성
echo " container$i:" >> docker-compose.yaml
echo " image: your_image_name:latest" >> docker-compose.yaml
echo " networks:" >> docker-compose.yaml
echo " - macvlan" >> docker-compose.yaml
echo " mac_address: $MAC_ADDRESS" >> docker-compose.yaml
echo " volumes:" >> docker-compose.yaml
echo " - /path/to/host/directory$i:/path/in/container" >> docker-compose.yaml
done
댓글 없음:
댓글 쓰기