Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to orchestrate Docker containers

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Docker Container is an open source application container engine that allows developers to package their applications and dependencies into a portable container in a unified way, and then publish them to any server with docker engine installed (including popular Linux machines, windows machines), and can also implement virtualization. Containers are completely sandboxed and do not have any interface to each other (similar to iPhone's app). There is almost no performance overhead and can be easily run in machines and data centers. Most importantly, they do not rely on any language, framework, including systems.

Step 1: create the yml file [root@host1 ~] # vim docker-compose.ymlversion: '3'services: web: image: nginx:latest ports:-"5000 root@host1 5000" links:-redis redis: image: redis step 2: launch the container [root@host1 ~] # docker-compose up-d step 3: check the status of the process started through compose [root@host1 ~] # docker-compose ps Name Command State Ports- -root_redis_1 docker-entrypoint.sh redis... Up 6379/tcp root_web_1 nginx-g daemon off; Up 0.0.0.0 root@host1 5000-> 5000/tcp, 80/tcp step 4: view log information [root@host1 ~] # docker-compose logs step 5: shut down the service [root@host1 ~] # docker-compose down Stopping root_web_1. DoneStopping root_redis_1... DoneRemoving root_web_1... DoneRemoving root_redis_1... DoneRemoving network root_default case 2 first step: create the Dockerfile file [root@host1 ~] # vim Dockerfile#Nginx#Version 1.0.1#Author zxhk#Base imageFROM centos:7#MaintainerMAINTAINER zxhk08@qq.com#CommandsRUN rpm-ivh http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpmRUN yum install-y nginxRUN echo "daemon off "> > / etc/nginx/nginx.confEXPOSE 80CMD [" nginx "] step 2: execute the Dockerfile file [root@host1 ~] # docker build-t newweb/nginx:v1-1. / step 3: build docker-compose.yml [root@host1 ~] # vim docker-compose.ymlversion: '2'services: web1: image: newweb/nginx:v1.0.1 volumes:-/ data/www1:/usr/share/nginx/html ports:- "8080 web2 80" web2: image: newweb/nginx:v1.0.1 volumes:-/ data/www2:/usr/share/nginx/html ports:-"8081 data/www2:/usr/share/nginx/html ports 80" web3: image: newweb/nginx:v1.0.1 volumes:-/ data/www3:/usr/share/nginx/html ports:-"8082 data/www2:/usr/share/nginx/html ports 80" step 4: start building [8082] # docker-compose up-d step 5: check the status of the process started through compose [root@host1 ~] # docker-compose ps step 6: view log information [root@host1 ~] # docker-compose logs step 7: shut down the service [root@host1 ~] # docker-compose down

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report