docker初体验(docker部署nginx服务)

Docker 是一个用于开发,交付和运行应用程序的开放平台。Docker 使您能够将应用程序与基础架构分开,从而可以快速交付软件。今天来为大家演示一下docker部署nginx
docker初体验:docker部署nginx服务docker初体验:docker部署nginx服务
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
【docker初体验(docker部署nginx服务)】[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
验证
docker初体验:docker部署nginx服务docker初体验:docker部署nginx服务

    推荐阅读