惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Blog — PlanetScale
Blog — PlanetScale
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
P
Privacy International News Feed
Forbes - Security
Forbes - Security
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Last Week in AI
Last Week in AI
C
CERT Recently Published Vulnerability Notes
月光博客
月光博客
NISL@THU
NISL@THU
美团技术团队
T
Tailwind CSS Blog
Jina AI
Jina AI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Apple Machine Learning Research
Apple Machine Learning Research
C
Cisco Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
The Hacker News
The Hacker News
B
Blog
P
Palo Alto Networks Blog
L
Lohrmann on Cybersecurity
有赞技术团队
有赞技术团队
The Register - Security
The Register - Security
S
Securelist
A
Arctic Wolf
MyScale Blog
MyScale Blog
H
Help Net Security
N
Netflix TechBlog - Medium
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
Threatpost
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Security Latest
Security Latest
T
Tor Project blog
V
Vulnerabilities – Threatpost
V
V2EX
AI
AI
Hugging Face - Blog
Hugging Face - Blog
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
Simon Willison's Weblog
Simon Willison's Weblog
小众软件
小众软件
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
H
Hackread – Cybersecurity News, Data Breaches, AI and More
T
Troy Hunt's Blog
Schneier on Security
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
H
Heimdal Security Blog
Google Online Security Blog
Google Online Security Blog
Know Your Adversary
Know Your Adversary

卡卡罗特

最后代码 | 卡卡罗特 swagger文档 | 卡卡罗特 react脚手架开发 | 卡卡罗特 python的对象增强 | 卡卡罗特 langchain实现Agent | 卡卡罗特 03.python列表集合元组字典 | 卡卡罗特 python依赖打包 | 卡卡罗特 python的异步 | 卡卡罗特 python的生成器 | 卡卡罗特 eino整合Tools | 卡卡罗特 eino实现Agent | 卡卡罗特 eino整合RAG | 卡卡罗特 docker打包go服务 | 卡卡罗特 docker-compose | 卡卡罗特 dockerfile | 卡卡罗特 linux安装docker | 卡卡罗特 hertz中间件 | 卡卡罗特 go整合向量数据库ChromaDB | 卡卡罗特 langchainjs | 卡卡罗特 ollama调用各大模型 | 卡卡罗特 spring-ai | 卡卡罗特 自定义一个MCP | 卡卡罗特 context.Context是什么? | 卡卡罗特 01-获取指定网站的所有的链接 | 卡卡罗特 01-Bing每日一图接口 | 卡卡罗特 02-腾讯API高清QQ头像https调用接口 | 卡卡罗特 openCV初体验 | 卡卡罗特 go字符串工具类 | 卡卡罗特 RWMutex读写锁 | 卡卡罗特 SyncMap的使用 | 卡卡罗特 defer的使用 | 卡卡罗特
01-docker入门 | 卡卡罗特
2026-05-12 · via 卡卡罗特

01-docker入门 ​

docker启动 ​

wsl中的原生docker ​

shell

## 非后台启动
sudo dockerd

## dockerd 后台运行
sudo dockerd > /var/log/docker.log 2>&1 &

测试docker是否可以正常拉取镜像 ​

我们挑一个小一点的测试

查看docker版本 ​

镜像 ​

查看

shell

## 查看镜像列表
docker images

删除

shell

# 删除镜像(需要先删除使用该镜像的容器)
docker rmi <镜像ID或名>

# 强制删除镜像
docker rmi -f <镜像ID或名>

# 示例
docker rmi chromadb/chroma
docker rmi d8c794af-a803



##  删除多个镜像
# 删除多个指定镜像
docker rmi image1 image2 image3

# 示例
docker rmi chromadb/chroma ubuntu:latest nginx:alpine

修改镜像名称

shell

# 注意  docker里面 镜像没有原地改名  只有复制一份 换新名字  但是可以先复制  再删除的方法实现原地改名
# 第一步:贴上新标签(复制引用) 此时,系统里有两个名字指向同一个镜像 ID。
docker tag nginx:1.14 my-nginx:v1
# 第二步:撕掉旧标签(删除旧名)
docker rmi nginx:1.14



# 注意 tag的主要用途是将镜像给推送到私有仓库  需要名字标准化 [registry]/[repository]:[tag]
docker tag nginx-test:1.14 harbor.example.com/nginx-test:1.4
# docker push   就是将镜像推送到了   harbor.example.com
docker push  harbor.example.com/nginx-test:1.4

打包镜像/加载镜像

还是很有用的,毕竟镜像我们无法导出给别人,但是我们可以将镜像打包成tar发给别人

shell

docker save nginx:1.14 -o test.tar

docker load < test.tar

容器 ​

查看

shell

## 查看正在运行的容器
docker ps

##  查看所有容器(包括已停止的)
docker ps -a

## 查看最新创建的容器
docker ps -l

## 查看最后创建的 5 个容器
docker ps -n 5

## 查看容器的详细信息
docker inspect 容器id

删除

shell

# 删除已停止的容器
docker rm <容器ID或名>

# 强制删除正在运行的容器
docker rm -f <容器ID或名>

# 示例
docker rm my-chroma-container
docker rm -f d8c794af-a803



##  删除多个容器
# 删除多个指定容器
docker rm container1 container2 container3

# 使用空格分隔多个容器ID或名称
docker rm d8c794af a3b2c1d4 my-container

运行容器

shell

## 运行容器并进入容器内部
docker run -it centos:7 /bin/bash
exit  # 退出容器

## 后台运行
docker run -d --name my-centos centos:7

## 开机自启动  2种方式
docker run  --restart=always -d --name my-nginx nginx:1.4
docker update 容器id/名字  --restart=always

# 进入已在后台运行的容器
docker exec -it my-centos /bin/bash

shell

docker run -d -p 8080:8080 --name my-go-app myapp
  • my-go-app 自定义的容器名称
  • myapp 指定的镜像名称

停止容器

shell

docker stop my-centos

启动已停止的容器

shell

docker start my-centos

查看容器状态

修改容器名字

shell

docker rename <容器id>  <新名>

拷贝文件到容器

shell

touch 1.txt
#把本地文件拷进容器
docker cp 1.txt 容器名:路径
## 启动容器
docker start 容器名
#进入容器
docker exec -it 容器名 bash

容器转成镜像

shell

docker commit -m "test commit"  <容器id/容器名>  <新镜像名>

构建dockerfile ​

假设你的项目根目录下有一个 Dockerfile,你可以这样构建:

shell

docker build -t myapp:1.0 .
  • 使用当前目录(.)作为构建上下文;
  • 读取该目录下的 Dockerfile;
  • 构建一个名为 myapp、标签为 1.0 的镜像。

其他常用选项: ​

  • -f:指定 Dockerfile 文件名(如果文件不叫 Dockerfile

    bash

    docker build -t myapp -f ./path/to/Dockerfile.custom .
  • --no-cache:构建时不使用缓存

    bash

    docker build --no-cache -t myapp .
  • --build-arg:传递构建参数(需在 Dockerfile 中用 ARG 声明)

    bash

    docker build --build-arg VERSION=1.2.3 -t myapp .