Goal: Build WordPress in Docker
Installation Order:
- First of all to have a cloud server---to buy or build it yourself (i installed a virtual machine on the host, built a ubuntu14.04)
- Installing Docker
- Installing Docker Compose
- Install WordPress
What is Docker
- Dockers is open-source and is
- Docker is a container where you can install software to build the environment, much like a virtual machine, but faster and lighter
- The core of Docker is mirroring
- Docker Learning link Chinese: https://yeasy.gitbooks.io/docker_practice/
- Docker English Document: https://docs.docker.com/
Installing Docker
- Docker has a commercial version and community version of two, we use the community version of the Docker CE
- Several versions of Ubuntu are supported:
- 14.04 LTS
- 16.04 LTS
- 17.01 (Docker CE 17.11 Edge and higher only)
- Refer to Official document installation https://docs.docker.com/install/linux/docker-ce/ubuntu/#os-requirements
- The installation steps are as follows, very simple
Update the addresses of the sources listed in/etc/apt/source.list and/ETC/APT/SOURCES.LIST.D (update apt package index)
~# sudo apt-get update
Allow apt to use warehouses over HTTPS when installing packages
~# sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
Add Docker official GPG key
~# curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Search for 8 digits after the fingerprint to confirm that the fingerprint is already 9dc8 5822 9fc7 DD38 854A e2d8 8d81 803C 0EBF CD88 key
~# sudo apt-key fingerprint 0EBFCD88输出:pub 4096R/0EBFCD88 2017-02-22 Key fingerprint = 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88uid Docker Release (CE deb) <[email protected]>sub 4096R/F273FCD8 2017-02-22
Set up Stble Warehouse, you can add word edege or test after stable word on command line, or two plus (different command line entered by operating system, see Official document)
~# sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Update APT Package index
~# sudo apt-get update
Install DOCKER-CE, the latest version is installed as follows
~# sudo apt-get install docker-ce
You can also make a version of Docker-ce, as follows
先查下都有哪些版本~# apt-cache madison docker-ce输出:docker-ce | 18.03.0~ce-0~ubuntu | https://download.docker.com/linux/ubuntu xenial/stable amd64 Packages
再指定版本安装,for example: sudo apt-get install docker-ce=18.03.0~ce-0~ubuntusudo apt-get install docker-ce=<VERSION>
Command line input docker run Hello-world check for successful installation
Installing Docker Compose
Official Installation Documentation: https://docs.docker.com/compose/install/#install-compose
Here is the PIP installation, first install PIP, such as the following command
~# apt-get install python-pip
PIP has been installed, directly below this command ( How to determine the PIP installation: directly enter the following command, if not installed will prompt )
~# pip install docker-compose
Check that the installation was successful, enter the following command
~# docker-compose -version
Install WordPress
Official website Installation document: https://docs.docker.com/compose/wordpress/#build-the-project
Create a project name, such as mywordpress (which directory can be created)
~# mkdir mywordpress
Enter the project file
~# cd my_wordpress
Create a Dcoker-compose.yml file
~# vim docker-compose.yml
The file contents are as follows
version: ‘3.3‘services: db: image: mysql:5.7 volumes: - db_data:/var/lib/mysql restart: always environment: MYSQL_ROOT_PASSWORD: somewordpress MYSQL_DATABASE: wordpress MYSQL_USER: wordpress MYSQL_PASSWORD: wordpress wordpress: depends_on: - db image: wordpress:latest ports: - "8000:80" restart: always environment: WORDPRESS_DB_HOST: db:3306 WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: wordpressvolumes: db_data:
Enter 0.0.0.0:8000 in the browser and follow the steps to install it.
Ubuntu system uses Docker to build WordPress