Complete Dockerfile instruction reference list

This commit is contained in:
yeasy
2026-04-27 23:17:39 +00:00
parent 3d3befa16a
commit 16203c5018
16 changed files with 86 additions and 102 deletions
+5 -5
View File
@@ -53,7 +53,7 @@ docker network inspect my-overlay-net
docker service create --name web \
--network my-overlay-net \
--replicas 3 \
nginx
nginx # 确保与环境兼容的 Nginx 版本
# 单机环境下也可以让普通容器加入 attachable overlay 网络
docker run -d --name container1 --network my-overlay-net busybox sleep 1d
@@ -111,14 +111,14 @@ docker run -d \
--dns 8.8.8.8 \
--dns 1.1.1.1 \
--dns-search example.com \
nginx
nginx # 确保与环境兼容的 Nginx 版本
# DNS 选项
docker run -d \
--dns-option ndots:2 \
--dns-option timeout:1 \
--dns-option attempts:3 \
nginx
nginx # 确保与环境兼容的 Nginx 版本
# 查看容器 DNS 配置
docker exec <container_id> cat /etc/resolv.conf
@@ -171,8 +171,8 @@ networks:
docker network create mynet
# 运行服务
docker run -d --name web --network mynet nginx
docker run -d --name db --network mynet postgres
docker run -d --name web --network mynet nginx # 确保与环境兼容的 Nginx 版本
docker run -d --name db --network mynet postgres # 确保与环境兼容的 PostgreSQL 版本
# 在其他容器中通过服务名访问
docker run -it --network mynet busybox sh