安装:
1 | brew install docker |
常用命令
使用
- Clone the repository:
从Github或DockerHub下载Docker仓库,
仓库中包含了你需要的构建和运行一个容器的所有内容。
1 | docker run --name repo alpine/git clone https://github.com/docker/getting-started.git |
- Build the image
一个Docker image 是一个给你的容器使用的私有文件系统,它包含了所有你的容器所需要的文件和代码。
1 | cd getting-started |
- Run
Start a container based on the image you built in the privious step.
启动在上一步编译的容器映像
1 | docker run -d -p 80:80 --name docker-tutorial docker101tutorial |
- Share
可以再DockerHub保存和分享你的image,以便让其他人可以在任何机器上下载和运行你的image。
1 | docker tag docker101tutorial {userName}/docker101tutorial |