Docker5 's Deploy your app

Source: Internet
Author: User
Tags ldap docker for mac docker run docker swarm docker machine aws console

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

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

    • The final version of from part docker-compose.yml 5 handy.

That is 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 apps on Popu Lar 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 "Docker Ize "VMs for you.
    • Use the Docker Cloud to create your computing resources and create your swarm.
    • Deploy your app.

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

Connect Docker Cloud

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

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

    • Amazon Web Services Setup Guide
    • Digitalocean Setup Guide
    • Microsoft Azure Setup Guide
    • Packet Setup Guide
    • SoftLayer Setup Guide
    • Use the Docker Cloud Agent to bring your own host

If you is running in Swarm mode (recommended for Amazon Web Services or Microsoft Azure) and then skip to the next section O n How to create your swarm.

Create your Swarm

Ready to create a swarm?

    • If you ' re on Amazon Web Services (AWS), you can automatically create a swarm on AWS.

    • If you is on Microsoft Azure, you can automatically create a swarm on Azure.

    • Otherwise, create your nodes in the Docker Cloud UI, and run the and commands your learned in part docker swarm init docker swarm join 4 over SSH V IA Docker Cloud. Finally, enable Swarm Mode by clicking the toggle on the top of the screen, and register the Swarm you just created.

If you is Using the Docker Cloud Agent to bring your Own Host, this provider does isn't 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 is a couple of different ways to connect:

      • from the Docker Cloud Web interface in Swarm mode, Sele CT swarms at the top of the page, click the swarm-want to connect to, and copy-paste the given command into a command Line Terminal.
      • on Docker for Mac or Docker for Windows, Can connect to your swarms dir Ectly through the Desktop app menus.
      • Either, this opens a terminal whose context was your local machine, but whose Docker commands is 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 getstarted Lab_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 is some examples that should look familiar by now:

    • Use to docker node ls 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 to docker service ls list services.
[Getstartedlab] ~/sandbox/getstart $ docker Service LsID                  NAME                       MODE                replicas            IMAGE                             PORTSX3JYX6UUKOG9        dockercloud-server-proxy   global              1/1                 dockercloud/server-proxy          *:2376-> 2376/TCPIOIPBY1VCXZM        Getstartedlab_redis        replicated          0/1                 redis:latest                      *:6379->6379/ Tcpu5cxv7ppv5o0        getstartedlab_visualizer   replicated          0/1                 dockersamples/visualizer:stable   *:8080->8080/tcpvy7n2piyqrtr        getstartedlab_web          replicated          5/5                 sam/getstarted: Part6    *:80->80/tcp
    • Use to docker service ps <service> view the tasks for a service.
[Getstartedlab] ~/sandbox/getstart $ docker Service PS Vy7n2piyqrtrid NAME IMAGE               NODE desired state Current state ERROR    Portsqrcd4a9lvjel getstartedlab_web.1 sam/getstarted:part6 ip-172-31-5-208.us-west-1.compute.internal Running Running seconds ago sknya8t4m51u getstartedlab_web.2 Sam/getstart                       Ed:part6 ip-172-31-6-237.us-west-1.compute.internal Running Running seconds ago             IA730LFNRSLG getstartedlab_web.3 sam/getstarted:part6 ip-172-31-20-217.us-west-1.compute.internal Running Running seconds ago 1edaa97h9u4k getstartedlab_web.4 sam/getstarted:part6 ip-        172-31-18-121.us-west-1.compute.internal Running Running seconds ago Uh64ez6ahuew Getstartedlab_web.5 sam/getstarted:part6 ip-172-31-18-121.us-west-1.compute.internal Running Running seconds ago
OPEN PORTS to SERVICES on CLOUD PROVIDER machines

At this point, your app. 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 web service on the worker nodes

    • Allow inbound traffic to the service on the worker nodes so, Hello world and web Visualizer is accessible from a we b Browser.

    • Allow inbound SSH traffic on the server which is running the the (this could be manager already set on your cloud provider)

These is the ports you need-expose for each service:

  

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

What is the Redis service to persist data?

redisto get the service working,

1.you need ssh to into the cloud server where manager the 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 pre-existing path on the manager server. This example does does include this step, so the service is not a in the redis example output.

We'll use the 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 the 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 would be something as this:

getstartedlab-nodevpcsg-9hv9smhdzt8c

4. Add Inbound Rules for web the, visualizer , and redis services, setting the Type, Protocol and ports for each as shown in th e table above, and click Save to apply the rules.

    

    

When you save the new rules, HTTP and TCP ports is 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 add Ress 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 this can do everything you learned about in previous parts of the tutorial.

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

    • The change of the app behavior by editing code, then rebuild, and push the new image. 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 a local Docker machine VMs, your swarm and any apps deployed on it W Ill continue to run on cloud servers regardless of whether your shut down your local host

Enterprise (Cloud Provider)

Customers of Docker Enterprise Edition run a stable, commercially-supported version of the Docker Engine, and as an add-on the Y 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 do Cker 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 is Amazon Web Services and Microsoft A Zure.

The good news Is:there is one-click templates to quickly deploy Docker Enterprise on each of the These providers:

    • Docker Enterprise for AWS
    • Docker Enterprise for Azure

Have 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 are 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 the Docker Engine, and as an add-on the Y 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 do Cker 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 both 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 are running, you can deploy your Compose file from directly within the UI. Ibid.

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

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 were covered here and you had a good idea of the basics of containers , images, services, swarms, stacks, scaling, load-balancing, volumes, and placement constraints.

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

    • Samples:our Samples include multiple examples of popular software running in containers, and some good labs this teach be St practices.
    • User Guide:the User Guide have several examples that explain networking and storage in greater depth than is 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 "s going on with Docker lately.

Docker5 's Deploy your app

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.