若是系統安裝舊版本Docker須要先卸載,命令以下:mysql
[root@localhost Wordpresss]sudo yum remove docker \ > docker-common \ > docker-selinux \ > docker-engine
[root@localhost Wordpresss]sudo yum install -y yum-utils \ > device-mapper-persistent-data \ > lvm2
[root@localhost Wordpresss]sudo yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo
[root@localhost Wordpresss]sudo yum install docker-ce
[root@localhost Wordpresss]sudo systemctl start docker
[root@localhost Wordpresss]docker version
[root@localhost Wordpresss]curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
[root@localhost Wordpresss]chmod +x /usr/local/bin/docker-compose
[root@localhost Wordpresss]docker-compose version
[root@localhost Wordpresss]mkdir /usr/local/wordpress
[root@localhost Wordpresss]cd /usr/local/wordpress
vi docker-compose.yml
linux
# docker-compose.yml 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: wordpress volumes: db_data:
[root@localhost Wordpresss]docker-compose up