设为首页 收藏本站
查看: 1031|回复: 0

[经验分享] How to Manage Docker Containers on Ubuntu-Arnold

[复制链接]

尚未签到

发表于 2019-2-19 08:56:29 | 显示全部楼层 |阅读模式
  Rancher is an open source container management platform. It allows you to run and manage Docker and Kubernetes containers with ease. Rancher provides infrastructure services such as multi-host networking, load balancing, and volume snapshots.
  In this tutorial, I will show you how to install and configure Rancher on Ubuntu 16.04 LTS. We will install Rancher on an Ubuntu server, enable local authentication, add the rancher host, and then try to run single container application from Rancher Dashboard.
Prerequisites

  •   Ubuntu Server 16.04

    •   hakase-labs - 192.168.33.10
    •   rancher-host01 - 192.168.33.11

  •   Root privileges
What we will do?

  •   Install Docker on Ubuntu 16.04
  •   Install Rancher Server
  •   Enable Local Authentication Rancher Server
  •   Add New Host
  •   Deploy New Container
Step 1 - Install Docker on Ubuntu 16.04
  Rancher can be installed as a set of Docker Containers - one container as a management server and another as an agent. And we need the Docker installed on all our rancher hosts.
  Update your Ubuntu repository and upgrade all packages.
  sudo apt update
  sudo apt upgrade
  Now install docker using the apt command below.
  sudo apt install -y docker.io
  After the installation is complete, start the docker service and enable it to run everytime at system boot.
  systemctl start docker
  systemctl enable docker
  The Docker is now installed and running on our rancher host - check it using the command below.
  systemctl status docker
  docker --version
  And you should get the result as shown below.
DSC0000.png

Step 2 - Install Rancher Server
  To run and install Rancher, we just need to run the Rancher container on our host. In this step, we will install Rancher server single container on our 'host01' server.
  Before installing Rancher server on the 'hakase-labs' server, we will create and define a new directory as a Rancher database volume.
  Run the following commands.
  HOST_VOLUME=$HOME/rancher-data/mysql
  mkdir -p $HOST_VOLUME
  Now install Rancher server using the docker command below.
  sudo docker run -d \
  -v $HOST_VOLUME:/var/lib/mysql \
  --restart=unless-stopped \
  -p 8080:8080 \
  rancher/server
  Wait for the Rancher server installation.
DSC0001.png

  When the installation is complete, Rancher server is accessible from the web browser.
  Open your web browser and type the server IP address with port 8080.
  http://192.168.33.10:8080/
  And you will get the Rancher first page installation as below.
DSC0002.png

Step 3 - Configure Rancher Access Control
  After the Rancher installation, we need to configure the Rancher Access Control. The Access Control allows you to manage users who have the access permissions to your Rancher server.
  Rancher supports many access control providers, including Active Directory, Azure AD, Github, OpenLDAP, SAML, and Local Authentication.
  For this guide, we will enable the local authentication for our Rancher server installation.
  Open your web browser and type the server IP address with port 8080.
  http://192.168.33.10:8080/
  Move the cursor to the 'ADMIN' menu and click the 'Access Control'.
DSC0003.png

  Now we want to use the 'Local Authentication' method. Click the 'LOCAL' on the page, then type your username and password.
DSC0004.png

  And click 'Enable Local Auth' button.
  And you will be redirected to the Rancher Dashboard with Local Authentication enabled.
DSC0005.png

Step 4 - Add New Host
  Hosts are the most basic unit of resource within Rancher and represented as any Linux server (a virtual or physical server with Docker installed on it).
  In this step, we will add new host 'rancher-host01' with Ubuntu as an operating system and 2GB RAM.
  Connect to the 'rancher-host01' server using the ssh.
  ssh rot@rancher-host01
  Install latest Docker version to the server using the apt command.
  sudo apt install docker.io
  After the installation is complete, start the docker service and enable it to launch everytime at system boot.
  systemctl start docker
  systemctl enable docker
  The Docker has been installed on the 'rancher-host01' server.
DSC0006.png

  Next, we will add the rancher-host01 to the Rancher Server.
  Open the Rancher Dashboard, move your cursor to the 'INFRASTRUCTURE' menu and click 'Hosts'.
DSC0007.png

  Now click 'Add Host' button.
DSC0008.png

  For the Host Registration URL, we will use default as below.
DSC0009.png

  Click the 'Save' button.
  Now select the Host type. Rancher support for many Host type including Amazon EC2, Azure, DigitalOcean, and Rackspace Hosts.
  Choose the 'Custom' host, type the 'hots02' IP address, and copy the docker command in the box.
DSC00010.png

  Now open the rancher-host01 terminal shell and paste the command as an example below.
  sudo docker run -e CATTLE_AGENT_IP="192.168.33.11"  --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.9 http://192.168.33.10:8080/v1/scripts/C7871D15E9CE6FFA892F:1514678400000:T9qDygb2pHroTMBuqA9Jylol8tU
  The command will download and create new container Rancher Agent on the rancher-host01 server.
  And when it's complete, you will get the result as below.
DSC00011.png

  Now back to the Rancher Dashboard Host Add page and click the 'Close' button.
  And you will get the page as below.
DSC00012.png

  rancher-host01 has been added to the Rancher server, and we're now ready to run container managed by Rancher server.
Step 5 - Test Create New Container through Rancher Catalog
  Rancher provides a catalog for applications. The application templates make it easy to deploy new applications.
  Rancher provides two types of catalogs. The Library catalog, which contains templates from the Rancher certified catalog, and the Community catalog, which contains templates from the Rancher Community-catalog.
  In this step, we will try to deploy a simple blog platform 'Ghost' as a container through the Rancher Catalog Community Templates.
  On the Rancher Dashboard, move the cursor to the 'CATALOG' menu and click the Community Catalog.
DSC00013.png

  I the 'Search' box - type the application name that we want to install ('Ghost'), then click the 'View Details' button.
DSC00014.png

  Give the new Ghost container a name and description.
DSC00015.png

  Then click the 'Launch' button.
  When it's complete, you will get the result as below.
DSC00016.png

  The 'Ghost' container has been created and is now running on the Rancher agent server.
  Now move your cursor to the 'INFRASTRUCTURE' menu and click the 'Host'. And make sure you get the 'ghost' container is running on the 'host2' server.
DSC00017.png

  To verify the Ghost container installation, open your web browser and type the 'rancher-host01' IP address and you will get the ghost blog default homepage.
  http://192.168.33.11/
DSC00018.png

  Rancher server and Rancher agent installation on Ubuntu 16.04 has been completed successfully.
Reference

  •   http://rancher.com/docs/


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-674160-1-1.html 上篇帖子: Ubuntu 下如何查看已安装的软件 下篇帖子: ubuntu固定mountd端口号
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表