Tutorial - Deploying a Docker-based Service

Deploying a Docker-based service

Create a custom Docker image

  1. Create a file named . Paste the following markup into index.html and save:

  2. Create a file named Dockerfile. Paste the following Docker commands into it and save:

    1. FROM nginx:1.9
    2. COPY index.html /usr/share/nginx/html/index.html
  3. Build the Docker image, where <username> is your Docker Hub username:

    1. docker build -t <username>/simple-docker .

    The output should resemble:

  4. Log in to Docker Hub:

      1. docker push <username>/simple-docker

      The output should resemble:

    Create a Docker app and deploy to DC/OS

    1. Create a Marathon app definition with the following contents and save as hello-nginx.json. In the image field, replace <username> with your Docker Hub username. In the field, specify MESOS or DOCKER depending on which you prefer. This file specifies a simple Marathon application called hello-nginx that runs one instance of itself on a public node.

      1. {
      2. "id": "hello-nginx",
      3. "container": {
      4. "type": "[MESOS | DOCKER]",
      5. "docker": {
      6. "image": "<username>/simple-docker"
      7. },
      8. "portMappings": [
      9. { "hostPort": 80, "containerPort": 80, "protocol": "tcp" }
      10. },
      11. "networks": [
      12. {
      13. }
      14. ],
      15. "acceptedResourceRoles": ["slave_public"],
      16. "instances": 1,
      17. "cpus": 0.1,
      18. "mem": 64
      19. }
    1. Add the hello-nginx application to Marathon by using the DC/OS command:

      If this is added successfully, there is no output.

    2. If you chose the MESOS runtime, you will see this when you verify that the app is added:

      1. In CloudFormation, check the checkbox next to your stack.
      2. Click the Resources tab.
      3. Search for PublicSlaveLoadBalancer.
      4. Click the link in the Physical ID column.
      5. Follow the instructions in Update the Health Check Configuration.

    Learn more

    Learn how to load balance your app on a public node using Marathon-LB.