• Make sure you have published the friendlyhello image you created by pushing it to a registry. We’ll be using that shared image here.

  • Be sure your image works as a deployed container. Run this command, slotting in your info for usernamerepo, and tagdocker run -p 80:80 username/repo:tag, then visit http://localhost/.

  • Have the final version of docker-compose.yml from Part 5handy.

That Compose file works just as well in production as it does on your machine.

Here, we’ll go through some options for running your Dockerized application.

Choose an option

Docer CE(Cloud provider)

If you’re okay with using Docker Community Edition in production, you can use Docker Cloud to help manage your app on popular service providers such as Amazon Web Services, DigitalOcean, and Microsoft Azure.

To set up and deploy:

  • Connect Docker Cloud with your preferred provider, granting Docker Cloud permission to automatically provision and “Dockerize” VMs for you.
  • Use Docker Cloud to create your computing resources and create your swarm.
  • Deploy your app.

  We will be linking into the Docker Cloud documentation here; be sure to come back to this page after completing each step.

Connect Docker Cloud

You can run Docker Cloud in standard mode or in Swarm mode.

If you are running Docker Cloud in standard mode, follow instructions below to link your service provider to Docker Cloud.

If you are running in Swarm mode (recommended for Amazon Web Services or Microsoft Azure), then skip to the next section on how to create your swarm.

Create your swarm

Ready to create a swarm?

   If you are Using the Docker Cloud Agent to Bring your Own Host, this provider does not support swarm mode. You can register your own existing swarms with Docker Cloud.

Deploy your app on a cloud provider

  1. Connect to your swarm via Docker Cloud. There are a couple of different ways to connect:

    • From the Docker Cloud web interface in Swarm mode, select Swarms at the top of the page, click the swarm you want to connect to, and copy-paste the given command into a command line terminal.

    • On Docker for Mac or Docker for Windows, you can connect to your swarms directly through the desktop app menus.
    • Either way, this opens a terminal whose context is your local machine, but whose Docker commands are routed up to the swarm running on your cloud service provider. You directly access both your local file system and your remote swarm, enabling pure docker commands.
  2. Run :to deploy the app on the cloud hosted swarm.
 docker stack deploy -c docker-compose.yml getstartedlab

 Creating network getstartedlab_webnet
Creating service getstartedlab_web
Creating service getstartedlab_visualizer
Creating service getstartedlab_redis

    Your app is now running on your cloud provider.

RUN SOME SWARM COMMANDS TO VERIFY THE DEPLOYMENT

You can use the swarm command line, as you’ve done already, to browse and manage the swarm. Here are some examples that should look familiar by now:

  • Use docker node ls to list the nodes.
[getstartedlab] ~ $ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
9442yi1zie2l34lj01frj3lsn ip-172-31-5-208.us-west-1.compute.internal Ready Active
jr02vg153pfx6jr0j66624e8a ip-172-31-6-237.us-west-1.compute.internal Ready Active
thpgwmoz3qefdvfzp7d9wzfvi ip-172-31-18-121.us-west-1.compute.internal Ready Active
n2bsny0r2b8fey6013kwnom3m * ip-172-31-20-217.us-west-1.compute.internal Ready Active Leader
  • Use docker service ls to list services.
[getstartedlab] ~/sandbox/getstart $ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
x3jyx6uukog9 dockercloud-server-proxy global 1/1 dockercloud/server-proxy *:2376->2376/tcp
ioipby1vcxzm getstartedlab_redis replicated 0/1 redis:latest *:6379->6379/tcp
u5cxv7ppv5o0 getstartedlab_visualizer replicated 0/1 dockersamples/visualizer:stable *:8080->8080/tcp
vy7n2piyqrtr getstartedlab_web replicated 5/5 sam/getstarted:part6 *:80->80/tcp
  • Use docker service ps <service> to view tasks for a service.
[getstartedlab] ~/sandbox/getstart $ docker service ps vy7n2piyqrtr
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
qrcd4a9lvjel getstartedlab_web.1 sam/getstarted:part6 ip-172-31-5-208.us-west-1.compute.internal Running Running 20 seconds ago
sknya8t4m51u getstartedlab_web.2 sam/getstarted:part6 ip-172-31-6-237.us-west-1.compute.internal Running Running 17 seconds ago
ia730lfnrslg getstartedlab_web.3 sam/getstarted:part6 ip-172-31-20-217.us-west-1.compute.internal Running Running 21 seconds ago
1edaa97h9u4k getstartedlab_web.4 sam/getstarted:part6 ip-172-31-18-121.us-west-1.compute.internal Running Running 21 seconds ago
uh64ez6ahuew getstartedlab_web.5 sam/getstarted:part6 ip-172-31-18-121.us-west-1.compute.internal Running Running 22 seconds ago

OPEN PORTS TO SERVICES ON CLOUD PROVIDER MACHINES

At this point, your app is deployed as a swarm on your cloud provider servers, as evidenced by the docker commands you just ran.

But, you still need to open ports on your cloud servers in order to:

  • allow communication between the redis service and webservice on the worker nodes

  • allow inbound traffic to the web service on the worker nodes so that Hello World and Visualizer are accessible from a web browser.

  • allow inbound SSH traffic on the server that is running the manager (this may be already set on your cloud provider)

These are the ports you need to expose for each service:

  

Methods for doing this will vary depending on your cloud provider.

What about the redis service to persist data?

  To get the redis service working,

  1.you need to ssh into the cloud server where the manager is running,

  2.and make a data/ directory in /home/docker/ before you run docker stack deploy.

   Another option is to change the data path in the docker-stack.yml to a pre-existing path on the manager server. This example does not include this step, so the redis service is not up in the example output.

We’ll use Amazon Web Services (AWS) as an example.

EXAMPLE: AWS

  1. Log in to the AWS Console, go to the EC2 Dashboard, and click into your Running Instances to view the nodes.
  2. On the left menu, go to Network & Security > Security Groups.You’ll see security groups related to your swarm for

    getstartedlab-Manager-<xxx>, getstartedlab-Nodes-<xxx>, and getstartedlab-SwarmWide-<xxx>.

  3.  select the “Node” security group for the swarm. The group name will be something like this:

    getstartedlab-NodeVpcSG-9HV9SMHDZT8C

  4.  Add Inbound rules for the webvisualizer, and redisservices, setting the Type, Protocol and Port for each as shown in the table above, and click Save to apply the rules.

    

    

    When you save the new rules, HTTP and TCP ports will be auto-created for both IPv4 and IPv6 style addresses.

  5. Go to the list of Running Instances, get the public DNS name for one of the workers, and paste it into the address bar of your web browser.  

Just as in the previous parts of the tutorial, the Hello World app displays on port 80, and the Visualizer displays on port 8080.

Iteration and cleanup

From here you can do everything you learned about in previous parts of the tutorial.

  • Scale the app by changing the docker-compose.yml file and redeploy on-the-fly with the docker stack deploy command.

  • Change the app behavior by editing code, then rebuild, and push the new image. (To do this, follow the same steps you took earlier to build the app and publish the image).

  • You can tear down the stack with docker stack rm. For example:

docker stack rm getstartedlab

Unlike the scenario where you were running the swarm on local Docker machine VMs, your swarm and any apps deployed on it will continue to run on cloud servers regardless of whether you shut down your local host

Enterprise(Cloud provider)

Customers of Docker Enterprise Edition run a stable, commercially-supported version of Docker Engine, and as an add-on they get our first-class management software, Docker Datacenter.

You can manage every aspect of your application via UI using Universal Control Plane, run a private image registry with Docker Trusted Registry, integrate with your LDAP provider, sign production images with Docker Content Trust, and many other features.

Take a tour of Docker Enterprise Edition

The bad news is: the only cloud providers with official Docker Enterprise editions are Amazon Web Services and Microsoft Azure.

The good news is: there are one-click templates to quickly deploy Docker Enterprise on each of these providers:

  Having trouble with these? View our setup guide for AWS. You can also view the WIP guide for Microsoft Azure.

Once you’re all set up and Datacenter is running, you can deploy your Compose file from directly within the UI.

After that, you’ll see it running, and can change any aspect of the application you choose, or even edit the Compose file itself.

Enterprise(on-premis)

Customers of Docker Enterprise Edition run a stable, commercially-supported version of Docker Engine, and as an add-on they get our first-class management software, Docker Datacenter. You can manage every aspect of your application via UI using Universal Control Plane, run a private image registry with Docker Trusted Registry, integrate with your LDAP provider, sign production images with Docker Content Trust, and many other features.

Take a tour of Docker Enterprise Edition

Bringing your own server to Docker Enterprise and setting up Docker Datacenter essentially involves two steps:

  1. Get Docker Enterprise Edition for your server’s OS from Docker Store.
  2. Follow the instructions to install Datacenter on your own host.

  Running Windows containers? View our Windows Server setup guide.

  Once you’re all set up and Datacenter is running, you can deploy your Compose file from directly within the UI.(同上)

  After that, you’ll see it running, and can change any aspect of the application you choose, or even edit the Compose file itself.(同上)

Congratulations!

You’ve taken a full-stack, dev-to-deploy tour of the entire Docker platform.

There is much more to the Docker platform than what was covered here, but you have a good idea of the basics of containers, images, services, swarms, stacks, scaling, load-balancing, volumes, and placement constraints.

Want to go deeper? Here are some resources we recommend:

  • Samples: Our samples include multiple examples of popular software running in containers, and some good labs that teach best practices.
  • User Guide: The user guide has several examples that explain networking and storage in greater depth than was covered here.
  • Admin Guide: Covers how to manage a Dockerized production environment.
  • Training: Official Docker courses that offer in-person instruction and virtual classroom environments.
  • Blog: Covers what’s going on with Docker lately.

Docker5之Deploy your app的更多相关文章

  1. Docker:Deploy your app

    Prerequisites Install Docker. Get Docker Compose as described in Part 3 prerequisites. Get Docker Ma ...

  2. Deploy Flask app to Apache on Windows

    内容已过期,分割线以下为原文存档. 故事背景 这次我需要将一个Flask应用部署到本地的Windows服务器上.操作系统是64位的,程序是基于Python 3开发的,大体就是这样. 部署选项 根据Fl ...

  3. How Do I Deploy a Windows 8 App to Another Device for Testing?

    If your developing a new Windows 8 app and you want to test it on another device (e.g. Surface), you ...

  4. [转]Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on (C#)

    本文转自:https://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-o ...

  5. Deploy .NET Core with Docker

    Creating a .NET Core project If you already have an existing .NET Core project you are more than wel ...

  6. Setting up PhoneGap on Ubuntu for Android app development

    This is just some notes I made, mostly taken from http://docs.phonegap.com/en/3.0.0/guide_overview_i ...

  7. 第二十一章:deploy and live updates

    通常我们开发一个app之后,需要把他们放到对应的应用商店上去以供下载.在此期间,需要经过应用商店的审核,包括初次上传和更新上传.短则需要数天,多则需要几个星期,这对于我们的快速产品迭代和hotfix来 ...

  8. 使用create react app教程

    This project was bootstrapped with Create React App. Below you will find some information on how to ...

  9. 5 Options for Distributing Your iOS App to a Limited Audience

    http://mobiledan.net/2012/03/02/5-options-for-distributing-ios-apps-to-a-limited-audience-legally/ I ...

随机推荐

  1. Spark学习之路 (五)Spark伪分布式安装

    一.JDK的安装 JDK使用root用户安装 1.1 上传安装包并解压 [root@hadoop1 soft]# tar -zxvf jdk-8u73-linux-x64.tar.gz -C /usr ...

  2. DeepLearning资源汇总

    仍旧不完全统计,边学边加 Bagging与随机森林算法原理 分类数据集 MNIST Cifar10 ILSVRC排行榜 Cifar10 board train loss与test loss结果分析   ...

  3. Linux基础命令---文本显示od

    od 将指定文件的内容以八进制.十进制.十六进制等编码方式显示.此命令的适用范围:RedHat.RHEL.Ubuntu.CentOS.SUSE.openSUSE.Fedora. 1.语法       ...

  4. SQL数据库增量备份还原方式

    SQLSERVER2008的备份还原最基本的方式自然是完整备份,然后完整还原即可. 但是如果遇到数据库文件很大,数据量很大,备份和还原需要花费不少时间的时候, 数据库的差异备份自然就成为考虑的备份方案 ...

  5. sparkStrming 实时插入 mysql 今天使用echart 实现了简单数据展示 很low 但学习必须加深

  6. window JNI_CreateJavaVM启动java程序

    https://blog.csdn.net/earbao/article/details/51889605 #define _CRT_SECURE_NO_WARNINGS 1       #inclu ...

  7. 保存canvas

    http://www.crazybunqnq.com/2018/09/01/PythonSeleniumSaveCanvas/ http://www.webhek.com/post/save-canv ...

  8. Python 2、8、10、16进制间的转换

    进制转换一直是初学者所头疼的,下面就简单的列出各进制之间都是以什么方式转换的. # print('2-->8: ', oct(int('0b1010', 2))) # 2-10-8 # prin ...

  9. P4890 Never·island(dp)

    P4890 Never·island 求门开的最小时间,其实也就是求门关的最大时间. 坐标这么大....显然坐标要离散化 离散化排序后,我们发现x轴被这些点划分成若干条线段$(l,r)$,并且有4种情 ...

  10. 在见证了1000多家公司的兴衰灭亡之后,YC创始合伙人总结了创业公司的6个不死法则(转)

    今天,我想先说一下个人消息.在 YC 工作了 11 年之后,我明年想去休假.我希望把精力放在一些项目上,说实话,我有点累了. YC 是这世界上我最喜欢的事情之一,但它也很费精力. 11 年不间断的耗费 ...