版本信息
docker版本信息
Client:
Version: 1.13.1
API version: 1.26
Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7f2769b/1.13.1
Built: Sun Sep 15 14:06:47 2019
OS/Arch: linux/amd64
Server:
Version: 1.13.1
API version: 1.26 (minimum version 1.12)
Package version: docker-1.13.1-103.git7f2769b.el7.centos.x86_64
Go version: go1.10.3
Git commit: 7f2769b/1.13.1
Built: Sun Sep 15 14:06:47 2019
OS/Arch: linux/amd64
Experimental: false
運(yùn)行nginx鏡像
搜索nginx鏡像
docker search nginx
下載nginx鏡像
docker pull docker.io/nginx
啟動(dòng)默認(rèn)nginx鏡像
docker run -d -p 80:80 --name nginx docker.io/nginx
復(fù)制nginx相關(guān)配置
# 復(fù)制配置文件
docker cp nginx:/etc/nginx/nginx.conf /opt/nginx/nginx.conf
# 復(fù)制conf.d
docker cp nginx:/etc/nginx/conf.d /opt/nginx/conf.d
停止并移除nginx鏡像
# 停止鏡像
docker stop nginx
# 移除鏡像
docker rm nginx
重新啟動(dòng)nginx鏡像
docker run --name nginx -d -p 80:80
-v /opt/nginx/nginx.conf:/etc/nginx/nginx.conf
-v /opt/nginx/conf.d:/etc/nginx/conf.d
-v /opt/nginx/logs:/var/log/nginx docker.io/nginx
常見問題
錯(cuò)誤描述
nginx鏡像中系統(tǒng)時(shí)間錯(cuò)誤蔬崩,與宿主機(jī)時(shí)間相差8小時(shí)
錯(cuò)誤解決
# 常見的解決方式可以掛載宿主機(jī)系統(tǒng)時(shí)間,啟動(dòng)時(shí)添加如下參數(shù):
-v /etc/localtime:/etc/localtime
# 完整命令
docker run --name nginx -d -p 80:80
-v /etc/localtime:/etc/localtime
-v /opt/nginx/nginx.conf:/etc/nginx/nginx.conf
-v /opt/nginx/conf.d:/etc/nginx/conf.d
-v /opt/nginx/logs:/var/log/nginx docker.io/nginx