docker-compose创建第一个应用
目录
一、编写docker-compose.yml文件
# vim docker-compose.yml
version: '2'
services:
web:
image: nginx:1.19.9-alpine
restart: always
ports:
- 80:80
二、启动应用
[root@k8s nginx]# docker-compose up -d
Creating network "nginx_default" with the default driver
Creating nginx_web_1 ... done
三、查看应用状态
[root@k8s nginx]# docker-compose ps
Name Command State Ports
---------------------------------------------------------------------------
nginx_web_1 /docker-entrypoint.sh ngin ... Up 0.0.0.0:80->80/tcp
四、停止应用
[root@k8s nginx]# docker-compose stop
Stopping nginx_web_1 ... done
五、移除应用
[root@k8s nginx]# docker-compose down
Stopping nginx_web_1 ... done
Removing nginx_web_1 ... done
Removing network nginx_default