Docker 环境搭建
目的
Docker就像一个船舱,其相互之间不存在接口。在一个资源隔离的环境中,开发者编写、测试、打包应用程序,然后通过Docker将程序和依赖环境一起部署到其他物理机上。
环境
CentOS x86
Docker CE 社区版
- 依赖库
> yum install -y yum-utils device-mapper-persistent-data lvm2
...
Complete!
- 添加Docker CE软件源
> yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- 安装Docker CE
> yum makecache fast
> yum -y install docker-ce
- 启动Docker
> systemctl start docker
使用阿里云远程镜像
- 阿里云控制台 --> 容器镜像服务 --> 镜像加速器
> sudo mkdir -p /etc/docker
> sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://<*****>.mirror.aliyuncs.com"]
}
EOF
> sudo systemctl daemon-reload
> sudo systemctl restart docker
试一下部署Nginx
> docker search nginx # 列出
> docker pull nginx:latest # 更新
> docker images # 查看
> docker run --name nginx-test -p 8080:80 -d nginx # 运行
-
访问Nginx,需要开放8080端口
Welcome to nginx! If you see this page, the nginx web server is successfully installed and working. Further configuration is required. For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com. Thank you for using nginx.