共计 1533 个字符,预计需要花费 4 分钟才能阅读完成。
导读 | Docker 是一个用于开发,交付和运行应用程序的开放平台。Docker 使您能够将应用程序与基础架构分开,从而可以快速交付软件。今天来为大家演示一下 docker 部署 nginx |
环境
centos7
安装 docker
移除旧版本 docker
[root@chaols ~]# sudo yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
安装 yum-utils 包并设置稳定存储库
[root@chaols ~]# yum install -y yum-utils
安装 docker
[root@chaols ~]# yum install docker-ce docker-ce-cli containerd.io
启动 docker
[root@chaols ~]# systemctl start docker
查看 docker 镜像
刚刚安装 docker 是没有镜像的
[root@chaols ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
部署 nginx
下载 nginx 镜像
[root@chaols ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
e1acddbe380c: Pull complete
e21006f71c6f: Pull complete
f3341cc17e58: Pull complete
2a53fa598ee2: Pull complete
12455f71a9b5: Pull complete
b86f2ba62d17: Pull complete
Digest: sha256:4d4d96ac750af48c6a551d757c1cbfc071692309b491b70b2b8976e102dd3fef
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
创建 nginx 虚拟机
run 运行 -it 交互模式 –name 指定名字 -p 宿主机:docker 虚拟机 nginx 镜像名字 /bin/bash 启动容器后启动 bash
[root@chaols ~]# docker run -it --name chao.nginx -p 8080:80 nginx /bin/bash
root@8ebe4de10f2c:/# /etc/init.d/nginx start
2021/08/21 07:58:49 [notice] 11#11: using the "epoll" event method
2021/08/21 07:58:49 [notice] 11#11: nginx/1.21.1
2021/08/21 07:58:49 [notice] 11#11: built by gcc 8.3.0 (Debian 8.3.0-6)
2021/08/21 07:58:49 [notice] 11#11: OS: Linux 3.10.0-1160.el7.x86_64
2021/08/21 07:58:49 [notice] 11#11: getrlimit(RLIMIT_NOFILE): 1048576:1048576
root@8ebe4de10f2c:/# 2021/08/21 07:58:49 [notice] 12#12: start worker processes
2021/08/21 07:58:49 [notice] 12#12: start worker process 13
验证
正文完
星哥玩云-微信公众号