Deploy Docker service with

This guide helps you to deploy a Docker service using the D2C platform. .

There are different ways to deploy Docker services:

  • Using an official Docker image
  • Using a public (unofficial) Docker image
  • Building an image using any other Docker image. You can find an example in the article about creating a Varnish using a debian image
  • Building your own Docker image on DockerHub/other Docker Registry. Will be in a separate post.

In this article, I’m going to show the first two ways.

Denis Zaripov

Product manager

Why Docker?

A container image is a lightweight, stand-alone, executable package of a piece of software that includes everything needed to run it: code, runtime, system tools, system libraries, settings. Containers isolate software from its surroundings, for example, differences between development and staging environments and help reduce conflicts between teams running different software on the same infrastructure.

Please, check out the original Docker post about containers for a better understanding of all the benefits of the technology.


It’s easier to start if you have an already connected host.

You can start with our Demo host, but it is created only for one hour. If you need more time, please follow our guides for connecting cloud providers or connecting your own machine to D2C.

Creating Docker service

At first, you need to open or create any project and click “+Create service“. You will see a list of services which can be deployed with D2C:

 Let’s go ahead and click on the Docker bar.

Creating Docker service. Service settings


The name should start with a letter and contain up to 16 characters (Latin letters, numbers, hyphen).

Each service has its unique name. Services can communicate with each other by service names (or alias-names, e.g. servicename-1 or servicename). Moreover, we use them to create public domains like: [servicename]-[www].[accountID].[at] for your services which are served by NGINX or HAProxy. We will talk about edge services in the next articles.

Docker image
  • For official repositories specify just its name.
    Examples: wordpress, sentry ghost etc.
  • For public (unofficial) repositories published in DockerHub specify accountname/repositoryname.
    Examples: d2cio/varnishmillion12/varnish etc.
  • For public (unofficial) repositories published anywhere on the Internet specify a link to a Docker image.
    Examples: etc.

Specify a version of a Docker image using tag names.

Examples: 6.0, latest

Global dependencies

In this field, you can specify commands for installing global dependencies and modifying Docker image of your service. For modifying source code use Local dependencies.

Examples: pip install, bundle install, apt-get install, npm install -g

Creating Docker service. Application source

This block is not necessary and using for application services.


You can choose what to use for getting application sources. The most recommended is Git. If you use a private repository you should add an SSH key to your account. Here are manuals about adding SSH keys into your GitHub, BitBucket, GitLab accounts. Another way is to use Login/Password, but the best practice is to use SSH keys. 


Another method is to specify a link to sources. 

Protocols: http, https, ftp (for closed ftp you should specify login/password).
File formats: .tar.bz2, .tar.gz, .tar, .zip


Moreover, you can upload from your machine.

File formats:

Maximum size: 50MB

Creating Docker service. Ports 

This is an important part.

By default, application containers are started inside a private network and have dynamically assigned local IP addresses. Apps can reference each other by service name. It does not matter on which host the app is running – all private network intercommunication is transparent for all services in your account.

Access from the Internet is disabled by default (except edge services). You can enable access from the Internet while creating or editing service. For example, if you publish your application on port 3000, you can access it at ip_address_of_a_host:3000

Creating Docker service. Application source

Local dependencies and code’s preparation

Commands for installing local dependencies and making your code ready to work. Examples: npm installcomposer installbower install, etc. or do some for preparation: gulp buildgrunt build, etc.

Start command
Start command for your application
Initial commands
Commands which are executed only once on the first container after the first deploying a service. You can use it for populate a database or migration.
Environment variables

You can specify environment variables for your application. They can be edited after creating a service.

Creating Docker service. Advanced settings. Persistent data volumes

The first block in this area is Persistent data volumes.

D2C separates the application itself from its data. Docker volumes are used to store persistent data. Data is stored locally on the hosts. Any data which is generated by an application should be added to Persistent data volumes. All modifications outside of these directories will be deleted after restart/rebuild/redeploy of a container/service (Docker restores the original state of a container). 

When you have several containers and want to synchronise data between them you should mark “Sync” checkbox. We use Lsync for synchronisation.

However, we recommend storing user generated content in a cloud storage like Amazon S3 or CDN.

Volumes UID

Sometimes it needs to set an owner of volumes. You can do it specifying userID. Execute id command to find out userID in a container terminal.

Example: id odoo

Creating Docker service. Advanced settings. Configs

You can add your additional config files. These files do not change after restart/rebuild/redeploy of your applications. 

Click “+Add custom config” and specify a full path where it should be stored.

After that, fill it in.

Generating new config button, in this case, erase all content.

Creating Docker service. Select hosts

You can choose one or several hosts where the similar containers will be deployed. It’s not necessary at the start, and you can scale your services after deployment. Also, at this step you can create other hosts and choose them even they are not online yet. The containers will be deployed when they are ready. 

What next?

In the next article we talk about:

  • creating an edge service for services and add your custom domain with free Let’s Encrypt TLS certificates
  • scaling, balancing, updating sources, checking containers logs and metrics