Docker-compose.yml for mysql and phpmyadmin
Docker Compose makes dealing with the orchestration processes of Docker containers (such as starting up, shutting down, and setting up intra-container linking and volumes) really easy.
Step-1: Install docker and docker-compose, Create a file with name docker-compose.yml in a directory.
sudo apt-get update sudo apt-get install docker.io docker sudo apt-get install python-pip sudo pip install docker-compose
Step-2: Copy and paste the below line in the docker-compose.yml file
version: '2' services: db: image: mysql environment: - MYSQL_DATABASE=homestead - MYSQL_USER=homestead - MYSQL_PASSWORD=secret - MYSQL_ROOT_PASSWORD=root volumes: - ./db:/var/lib/mysql ports: - "3306:3306" phpmyadmin: image: phpmyadmin/phpmyadmin environment: PMA_ARBITRARY: 1 MYSQL_USER: homestead MYSQL_PASSWORD: secret MYSQL_ROOT_PASSWORD: root ports: - "80:80" links: # for mysql container - "db:db" volumes: db: driver: "local"
Step-3: Start the docker container with docker compose command like below
docker-compose up -d
Additional Step: Stop docker container
Note-: Browse on Web browser with ip, localhost or domain.