① 查看docker版本信息


先查看docker版本等信息,输入获取版本信息:

[root@docker1 ~]# docker version

Client:

 Version:         1.12.6

 API version:     1.24

 Package version: docker-1.12.6-61.git85d7426.el7.centos.x86_64

 Go version:      go1.8.3

 Git commit:      85d7426/1.12.6

 Built:           Tue Oct 24 15:40:21 2017

 OS/Arch:         linux/amd64


Server:

 Version:         1.12.6

 API version:     1.24

 Package version: docker-1.12.6-61.git85d7426.el7.centos.x86_64

 Go version:      go1.8.3

 Git commit:      85d7426/1.12.6

 Built:           Tue Oct 24 15:40:21 2017

 OS/Arch:         linux/amd64

[root@docker1 ~]# docker info

Containers: 12

 Running: 1

 Paused: 0

 Stopped: 11

Images: 133

Server Version: 1.12.6

Storage Driver: devicemapper

 Pool Name: docker-253:0-25843-pool

 Pool Blocksize: 65.54 kB

 Base Device Size: 10.74 GB

 Backing Filesystem: xfs

 Data file: /dev/loop0

 Metadata file: /dev/loop1

 Data Space Used: 11.53 GB

 Data Space Total: 107.4 GB

 Data Space Available: 1.073 GB

 Metadata Space Used: 15.47 MB

 Metadata Space Total: 2.147 GB

 Metadata Space Available: 1.073 GB

 Thin Pool Minimum Free Space: 10.74 GB

 Udev Sync Supported: true

 Deferred Removal Enabled: true

 Deferred Deletion Enabled: true

 Deferred Deleted Device Count: 0

 Data loop file: /var/lib/docker/devicemapper/devicemapper/data

 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.

 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata

 Library Version: 1.02.140-RHEL7 (2017-05-03)

Logging Driver: journald

Cgroup Driver: systemd

Plugins:

 Volume: local

 Network: null overlay bridge host

Swarm: inactive

Runtimes: docker-runc runc

Default Runtime: docker-runc

Security Options: seccomp selinux

Kernel Version: 3.10.0-693.5.2.el7.x86_64

Operating System: CentOS Linux 7 (Core)

OSType: linux

Architecture: x86_64

Number of Docker Hooks: 3

CPUs: 1

Total Memory: 472.3 MiB

Name: docker1

ID: 7WA2:LZJV:R2X2:EV57:DFTD:4TOC:CT26:DRLS:PTMU:RE4W:SX5P:FQ4E

Docker Root Dir: /var/lib/docker

Debug Mode (client): false

Debug Mode (server): false

Registry: https://index.docker.io/v1/

WARNING: bridge-nf-call-iptables is disabled

WARNING: bridge-nf-call-ip6tables is disabled

Insecure Registries:

 127.0.0.0/8

Registries: docker.io (secure)

docker信息可以输出表示docker运行成功


② 下载mysql镜像


我们先拉下来mysql镜像,然后设定mysql密码(我设的123456),指定mysql版本为最新版(latest)


[root@docker1 ~]# docker pull mysql

Using default tag: latest

Trying to pull repository docker.io/library/mysql ... 

latest: Pulling from docker.io/library/mysql

f49cf87b52c1: Pull complete 

78032de49d65: Pull complete 

837546b20bc4: Pull complete 

9b8316af6cc6: Pull complete 

1056cf29b9f1: Pull complete 

86f3913b029a: Pull complete 

4cbbfc9aebab: Pull complete 

8ffd0352f6a8: Pull complete 

45d90f823f97: Pull complete 

ca2a791aeb35: Pull complete 

Digest: sha256:1f95a2ba07ea2ee2800ec8ce3b5370ed4754b0a71d9d11c0c35c934e9708dcf1

[root@docker1 ~]# docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -p 4406:3306 -d mysql:latest

4710c01635048e6255348d40c706b93975c2bc73d8db8747ce98f8d7be82e858

[root@docker1 ~]# docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES

4710c0163504        mysql:latest        "docker-entrypoint.sh"   4 seconds ago       Up 3 seconds        0.0.0.0:4406->3306/tcp   some-mysql


7、启动WordPress博客系统


输入一下命令,表示使用mysql来启动WordPress,且把宿主机端口8088与ubuntu端口80进行绑定。


[root@docker1 ~]# docker run --name some-wordpress --link some-mysql:mysql -p 8088:80 -d wordpress

d80930fe7ad5ea3ddf8513117541140685759b4e5f22d70783acdf802504a272

[root@docker1 ~]# docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES

d80930fe7ad5        wordpress           "docker-entrypoint.sh"   5 seconds ago       Up 4 seconds        0.0.0.0:8088->80/tcp     some-wordpress

4710c0163504        mysql:latest        "docker-entrypoint.sh"   2 minutes ago       Up 2 minutes        0.0.0.0:4406->3306/tcp   some-mysql


此时,WordPress项目就跑起来了。


在本机输入localhost:8088,效果如下,是不是很酷!:


blob.png