少说话多写代码之Docker——001:Mac上安装docker

1、安装

docker官网找到for mac的安装包Docker.dmg文件下载安装即可。将docer拖到应用里。安装成功后任务栏会有docker标志。

配置镜像地址

打开任务栏图标,进入preferences,如下图配置镜像。比如可以配置这些镜像。

https://docker.mirrors.ustc.edu.cn

http://ead3d542.m.daocloud.io

http://hub-mirror.c.163.com

少说话多写代码之Docker——001:Mac上安装docker_第1张图片

2、验证安装

查看版本

打开终端,输入命令docker version,如下

yangyoushan$ docker version
Client: Docker Engine - Community
 Version:           18.09.2
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        6247962
 Built:             Sun Feb 10 04:12:39 2019
 OS/Arch:           darwin/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.2
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       6247962
  Built:            Sun Feb 10 04:13:06 2019
  OS/Arch:          linux/amd64
  Experimental:     true

启动ngnix容器

会自动下载镜像,运行如下

yangyoushan$ docker run -d -p80:80 --name webserver nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
6ae821421a7d: Pull complete 
58702d4af197: Pull complete 
b165f42e8fd4: Pull complete 
Digest: sha256:272dbcc93e9a1d312632f28927512152e53a6a0607e588489d1397c562c73f40
Status: Downloaded newer image for nginx:latest
d994280e330a824992449578ee77f4f22fd84746ffa6b57b7316443e088f4f07
YOUSHANYANG-MB0:~ yangyoushan$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
d994280e330a        nginx               "nginx -g 'daemon of…"   20 seconds ago      Up 19 seconds       0.0.0.0:80->80/tcp   webserver

输入:http://0.0.0.0:80,打开如下页面

少说话多写代码之Docker——001:Mac上安装docker_第2张图片

 

 

你可能感兴趣的:(docker)