Tutorial - Deploying a Docker-based Service
Deploying a Docker-based service
- installed on your workstation
- Docker Hub account
- installed
- DC/OS CLI installed
Create a custom Docker image
Create a file named . Paste the following markup into
index.html
and save:Create a file named
Dockerfile
. Paste the following Docker commands into it and save:FROM nginx:1.9
COPY index.html /usr/share/nginx/html/index.html
Build the Docker image, where
<username>
is your Docker Hub username:docker build -t <username>/simple-docker .
The output should resemble:
Log in to Docker Hub:
-
docker push <username>/simple-docker
The output should resemble:
Create a Docker app and deploy to DC/OS
Create a Marathon app definition with the following contents and save as
hello-nginx.json
. In theimage
field, replace<username>
with your Docker Hub username. In the field, specifyMESOS
orDOCKER
depending on which you prefer. This file specifies a simple Marathon application calledhello-nginx
that runs one instance of itself on a public node.{
"id": "hello-nginx",
"container": {
"type": "[MESOS | DOCKER]",
"docker": {
"image": "<username>/simple-docker"
},
"portMappings": [
{ "hostPort": 80, "containerPort": 80, "protocol": "tcp" }
},
"networks": [
{
}
],
"acceptedResourceRoles": ["slave_public"],
"instances": 1,
"cpus": 0.1,
"mem": 64
}
Add the
hello-nginx
application to Marathon by using the DC/OS command:If this is added successfully, there is no output.
If you chose the MESOS runtime, you will see this when you verify that the app is added:
-
- In CloudFormation, check the checkbox next to your stack.
- Click the Resources tab.
- Search for PublicSlaveLoadBalancer.
- Click the link in the Physical ID column.
- 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.