docker build WordPress for Centos7

6486 ワード

execute two docker commands [root@VM_0_7_centos ~]# docker run –name db –env MYSQL_ROOT_PASSWORD=example -d mariadb [root@VM_0_7_centos ~]# docker run –name MyWordPress –link db:mysql -p 8080:80 -d wordpress view images [root@VM_0_7_centos ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/wordpress latest 9414c91da9a8 9 days ago 408 MB docker.io/mariadb latest 2c73b3262fff 2 weeks ago 363 MB docker.io/hello-world latest 2cb0d9787c4d 4 weeks ago 1.85 kB view port [root@VM_0_7_centos~]#netstat-tlnp|grep 8080 tcp 6 0:::8080:::*LISTEN 11164/docker-proxy-アクセスurl:http://ip:8080/ user:user password:password mail:mail
http://ip:8080/wp-admin/
まず、WordPressプロジェクトの既存の2つの容器を停止します[root@VM_0_7_centos~]#docker stop db MyWordPressプロジェクトフォルダ~/wordpressを作成し、フォルダの下にdocker-composeという名前を作成します.ymlのファイル、内容は以下の通りです.
[root@VM_0_7_centos ~]# ls
grafana-5.1.1-1.x86_64.rpm  test  wordpress  zabbix-agent-3.4.8-1.el7.x86_64.rpm  zabbix-release-3.4-2.el7.noarch.rpm
[root@VM_0_7_centos ~]# cat wordpress/docker-compose.yml 
wordpress:
 image: wordpress
 links:
  - db:mysql
 ports:
  - 8080:80
db:
  image: mariadb
  environment:
    MYSQL_ROOT_PASSWORD: example

-links(コンテナ相互接続)、-ports(ポートマッピング)、-environment(環境変数設定)
WordPressサービスを作成して起動し、新しいNAMESを生成し、サービスUP
[root@VM_0_7_centos ~]# cd wordpress && docker-compose up
[root@VM_0_7_centos ~]# docker ps -a
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS                      PORTS                                                   NAMES
eed8e51c7189        wordpress                     "docker-entrypoint..."   30 minutes ago      Up 30 minutes               0.0.0.0:8080->80/tcp                                    wordpress_wordpress_1
f4ad894f2087        mariadb                       "docker-entrypoint..."   30 minutes ago      Up 30 minutes               3306/tcp                                                wordpress_db_1
aca92654af96        sameersbn/gitlab:8.4.4        "/sbin/entrypoint...."   About an hour ago   Up About an hour            443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp   gitlab
e92b61cf18c7        sameersbn/redmine:3.2.0-4     "/sbin/entrypoint...."   9 days ago          Up About an hour            443/tcp, 0.0.0.0:10083->80/tcp                          redmine
e038010f4bea        sameersbn/postgresql:9.4-12   "/sbin/entrypoint.sh"    9 days ago          Up About an hour            5432/tcp                                                postgresql-redmine
511be91cca0a        sameersbn/redis:latest        "/sbin/entrypoint.sh"    10 days ago         Up About an hour            6379/tcp                                                gitlab-redis
e9bba5e833b6        sameersbn/postgresql:9.4-12   "/sbin/entrypoint.sh"    10 days ago         Up About an hour            5432/tcp                                                gitlab-postgre-sql
8001906c5274        wordpress                     "docker-entrypoint..."   10 days ago         Exited (0) 33 minutes ago                                                           MyWordPress
da706ccdc499        mariadb                       "docker-entrypoint..."   10 days ago         Exited (0) 33 minutes ago                                                           db

次の起動方法:
“` [root@VM_0_7_centos ~]# cd wordpress/ [root@VM_0_7_centos wordpress]# docker-compose start [root@VM_0_7_centos wordpress]# docker-compose stop