Docker Compose MySQL server
examples/mysql/docker-compose.yml
version: '3.8' services: client: build: . volumes: - .:/opt links: - mysql command: tail -f /dev/null mysql: image: mysql:latest environment: MYSQL_ROOT_PASSWORD: secret
examples/mysql/Dockerfile
FROM ubuntu:22.04 RUN apt-get update && \ apt-get install -y curl && \ apt-get install -y inetutils-ping && \ apt-get install -y mysql-client && \ echo DONE
docker-compose up -d
docker exec -it mysql_client_1 bash
ping mysql
# mysql -h mysql --password=secret mysql> SELECT CURRENT_TIMESTAMP; mysql> exit
# echo "SELECT CURRENT_TIMESTAMP" | mysql -h mysql --password=secret