본문 바로가기

docker

docker-compose 쉘(shell) 사용법



yml(yaml)은 버전별로 양식이 다르니 유의하세요.

0. docker-compose.yml

version: '2'
services:
api:
ports:
- "5000:80"
- "5001:443"
build:
context: .
dockerfile: Dockerfile
# volumes:
# - ./:/var/www
depends_on:
- db
- cache
db:
image: mariadb
environment:
- "MYSQL_USER={{userid}}"
- "MYSQL_PASSWORD={{password}}"
- "MYSQL_ROOT_PASSWORD={{root_password}}"
- "MYSQL_DATABASE={{default_database}}"
ports:
- "3306:3306"
cache:
image: redis:5.0
ports:
- "6379:6379"

2. mysql
sudo docker exec -it test_db_1 sh
#mysql -h127.0.0.1 -uroot -p

3. redis
sudo docker exec -it test_cache_1 sh
#redis-cli