Skip to content

Instantly share code, notes, and snippets.

@tareq3
Last active April 4, 2020 12:22
Show Gist options
  • Save tareq3/d3ca58e44353d0a3db6b82d71bb65c57 to your computer and use it in GitHub Desktop.
Save tareq3/d3ca58e44353d0a3db6b82d71bb65c57 to your computer and use it in GitHub Desktop.

Create a folder with a meaningful name as this will be your container name

create a file named as docker-composer.yaml

paste following file

version: '3'  //version is important and defined by docker not custom

services:
  # Database
  db:
    image: mysql:latest #latest is the version tag for the docker image
    volumes:
      - db_data:/var/lib/mysql
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: password
      
    networks:
      - my-net   //as they will share same network, pass any custom network name
  # phpmyadmin
  phpmyadmin:
    depends_on:
      - db
    image: phpmyadmin/phpmyadmin
    restart: always
    ports:
      - '8080:80'
    environment:
      PMA_HOST: db 
      MYSQL_ROOT_PASSWORD: password 
    networks:
      - my-net  //pass same name as we declared for mysql
  
networks:
  my-net:
volumes:
  db_data:

for running :

$ docker-compose up -d

# To Tear Down
$ docker-compose down --volumes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment