Guest User

Untitled

a guest
May 15th, 2018
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. ## Setup for using Docker containers with Wordpress and MYSQL
  2. - New application
  3. - Run command
  4. - `docker-compose up -d`
  5. - Existing application
  6. - To ensure database container is loaded before Wordpress container is started
  7. you **MUST** start containers individually the first time development environment is setup
  8. - Start database container
  9. - `docker-compose up -d db - Replace db with the name of your database container`
  10. - Wait until database is running and loaded (10s is usually more than enough time)
  11. - Start your wordpress container
  12. - `docker-compose up -d wordpress - Replace db with the name of your database container`
  13. --
  14. ```
  15. # Refers to the docker-compose production version
  16. version: '3.3
  17. # Services are containers in production you would like to pull from
  18. services:
  19. # Database container config
  20. db:
  21. # Pulls the latest stable version of mysql
  22. # Change latest to specific version if needed (ie - mysql:version#)
  23. image: mysql:5.7.17
  24. # Creates a directory called db_data to store database information
  25. volumes:
  26. # creates new db located in the db_data directory
  27. - ./db:/var/lib/mysql
  28. # Load existing db from dump file located in this directory
  29. - "./db_data:/docker-entrypoint-initdb.d"
  30. ports:
  31. - "3306:3306"
  32. # Database container is always set to restart when start command entered
  33. restart: always
  34. # Set up specific variables for the database container
  35. # These must be the same as the Wordpress credentials to ensure database accessibility
  36. environment:
  37. MYSQL_ROOT_PASSWORD: root
  38. MYSQL_DATABASE: database name
  39. MYSQL_USER: user name
  40. MYSQL_PASSWORD: user password
  41. # Wordpress container config
  42. wordpress:
  43. # Will not start wordpress container unless db is up and running
  44. depends_on:
  45. - db
  46. # Pulls the latest stable version of wordpress
  47. # Change latest to specific version if needed (ie - wordpress:version#)
  48. image: wordpress:latest
  49. # Creates a directory called wordpress to store site information
  50. volumes:
  51. - "./wordpress:/var/www/html"
  52. # Set a port to expose the container to (ie - localhost:8000)
  53. ports:
  54. - "8000:80"
  55. # Database container is always set to restart when start command entered
  56. restart: always
  57. # Set up specific variables for the Wordpress container
  58. # WARNING - These will override settings you have in wp-config file
  59. environment:
  60. WORDPRESS_DB_HOST: db
  61. WORDPRESS_DB_NAME: database name
  62. WORDPRESS_DB_USER: user name
  63. WORDPRESS_DB_PASSWORD: user password
  64. # **Optional**
  65. # If set will make mounted volume data persistent
  66. volumes:
  67. db_data:
  68. ```
Add Comment
Please, Sign In to add comment