Deploy an app from the CLI

Estimated reading time: 1 minute

With Docker Universal Control Plane you can deploy your apps from the CLI, using Docker Compose. In this example we’re going to deploy a WordPress application.

Get a client certificate bundle

Docker UCP secures your Docker swarm with role-based access control, so that only authorized users can deploy applications. To be able to run Docker commands on a swarm managed by UCP, you need to configure your Docker CLI client to authenticate to UCP using client certificates.

Learn how to set your CLI to use client certificates.

Deploy WordPress

The WordPress application we’re going to deploy is composed of two services:

  • wordpress: The service that runs Apache, PHP, and WordPress.
  • db: A MariaDB database used for data persistence.

After setting up your Docker CLI client to authenticate using client certificates, create a file named docker-compose.yml with the following service definition:

version: '2'

     image: mysql:5.7
       - db_data:/var/lib/mysql
     restart: always
       MYSQL_ROOT_PASSWORD: wordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

       - db
     image: wordpress:latest
       - "8000:80"
     restart: always
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_PASSWORD: wordpress

In your command line, navigate to the place where you’ve created the docker-compose.yml file and deploy the application to UCP by running:

$ docker-compose --project-name wordpress up -d

Test that the WordPress service is up and running, and find on which node it was deployed.

$ docker-compose --project-name wordpress ps

Name                       Command               State             Ports
wordpress_db_1 mysqld      Up      3306/tcp                   
wordpress_wordpress_1 apach ...   Up>80/tcp

In this example, WordPress was deployed to Navigate to this address in your browser, to start using the WordPress app you just deployed.

Where to go next

chat icon Feedback? Suggestions? Can't find something in the docs?
Edit this page Request docs changes Get support
Rate this page: