nicenote/docs/tools/docker.md
2024-01-18 16:29:26 +08:00

64 lines
966 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
nav:
title: 工具
path: /tools
group:
title: 工具
order: 2
---
# Docker
## 通过 brew 下载
> brew cask install docker
## 设置国内镜像源
> preference -> deamon建议阿里云镜像源
## 测试 docker 是否可用
> docker run -d -p 80:80 --name webserver nginx
## 用 nginx 镜像启动一个容器,命名为 webserver
停止
```
docker stop webserver
docker rm webserver
```
进入上面命名后的 webserver 容器:
```
docker exec -it webserver bash (进入容器)
echo 'Hello, Docker!'
/usr/share/nginx/html/index.html修改容器内容
exit退出容器
commit 复制镜像
```
## 查看镜像近期的改动
> docker diff
## 提交信息
```
docker commit
--author "Tao Wang twang2218@gmail.com"
--message "修改了默认网页"
webserver
nginx:v2
```
## 查看该镜像的提交记录
> docker history nginx:v2
## 运行该镜像在 81 端口
> docker run --name web2 -d -p 81:80 nginx:v2