Last active
          October 6, 2015 08:51 
        
      - 
      
- 
        Save tristanlins/c3c233e66fed180d2f1c to your computer and use it in GitHub Desktop. 
    Using docker mariadb as local database
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | [client] | |
| user=root | |
| password=53CUr3-p422W0RD | |
| host=127.0.0.1 | |
| port=3306 | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # @file /etc/systemd/system/docker-mariadb.service | |
| # @see https://docs.docker.com/articles/host_integration/ | |
| [Unit] | |
| Description=MariaDB container | |
| Requires=docker.service | |
| After=docker.service | |
| [Service] | |
| Restart=always | |
| ExecStart=/usr/bin/docker start -a mariadb | |
| ExecStop=/usr/bin/docker stop -t 60 mariadb | |
| [Install] | |
| WantedBy=local.target | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # start container | |
| sudo systemctl start docker-mariadb | |
| # stop container | |
| sudo systemctl stop docker-mariadb | |
| # attach shell to container | |
| docker exec -it mariadb bash | |
| # see the logs | |
| docker logs mariadb | |
| # for more see | |
| # https://hub.docker.com/_/mariadb/ | |
| # https://docs.docker.com/articles/host_integration/ | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | # create config and data directory | |
| mkdir -p $HOME/docker/mariadb/{config,data} | |
| # initially create the docker container | |
| docker run --restart=on-failure:5 \ | |
| --volume=$HOME/docker/mariadb/config:/etc/mysql/conf.d \ | |
| --volume=$HOME/docker/mariadb/data:/var/lib/mysql \ | |
| --publish=3306:3306 \ | |
| --env=MYSQL_ROOT_PASSWORD=53CUr3-p422W0RD \ | |
| --hostname=mariadb \ | |
| --name=mariadb \ | |
| --detach=true \ | |
| mariadb:10 | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment