版本信息
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
运行nginx镜像
搜索nginx镜像
docker search nginx
下载nginx镜像
docker pull docker.io/nginx
启动默认nginx镜像
docker run -d -p 80:80 --name nginx docker.io/nginx
复制nginx相关配置
# 复制配置文件
docker cp nginx:/etc/nginx/nginx.conf /opt/nginx/nginx.conf
# 复制conf.d
docker cp nginx:/etc/nginx/conf.d /opt/nginx/conf.d
停止并移除nginx镜像
# 停止镜像
docker stop nginx
# 移除镜像
docker rm nginx
重新启动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
常见问题
错误描述
nginx镜像中系统时间错误,与宿主机时间相差8小时
错误解决
# 常见的解决方式可以挂载宿主机系统时间,启动时添加如下参数:
-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