Project: YugabyteDB (App Definition and Development / Database)
File: docker-compose.md

title: Deploy local clusters using Docker Compose headerTitle: Docker linkTitle: Docker description: Use Docker Compose to create and manage local YugabyteDB clusters. menu: v2.14: parent: deploy name: Docker identifier: docker-1-compose weight: 625 type: docs <ul class="nav nav-tabs-alt nav-tabs-yb"> <li> <a href="{{< relref "./docker-compose.md" >}}" class="nav-link active"> <i class="fa-brands fa-docker" aria-hidden="true"></i> Docker Compose </a> </li> </ul> Use utility to create and manage YugabyteDB local clusters. Note that this approach is not recommended for multi-node clusters used for performance testing and production environments. Refer to the to understand the configuration to create clusters. Make sure to have installed on your machine. Pull the container from Docker Hub registry. ```sh $ docker pull yugabytedb/yugabyte ``` <div class='copy'></div> ```sh version: '2' volumes: yb-master-data-1: yb-tserver-data-1: services: yb-master: image: yugabytedb/yugabyte:latest container_name: yb-master-n1 volumes: yb-master-data-1:/mnt/master command: [ "/home/yugabyte/bin/yb-master", "--fsdatadirs=/mnt/master", "--master_addresses=yb-master-n1:7100", "--rpcbindaddresses=yb-master-n1:7100", "--replication_factor=1"] ports: "7000:7000" environment: SERVICE7000NAME: yb-master yb-tserver: image: yugabytedb/yugabyte:latest container_name: yb-tserver-n1 volumes: yb-tserver-data-1:/mnt/tserver command: [ "/home/yugabyte/bin/yb-tserver", "--fsdatadirs=/mnt/tserver", "--enable_ysql", "--rpcbindaddresses=yb-tserver-n1:9100", "--tservermasteraddrs=yb-master-n1:7100"] ports: "9042:9042" "5433:5433" "9000:9000" environment: SERVICE5433NAME: ysql SERVICE9042NAME: ycql SERVICE6379NAME: yedis SERVICE9000NAME: yb-tserver depends_on: yb-master ``` ```sh $ docker-compose -f ./docker-compose.yaml up -d ``` YCQL and YSQL APIs are enabled by default on the cluster. Clients can now connect to the YSQL API at localhost:5433 and the YCQL API at localhost:9042. The yb-master admin service is available at http://localhost:7000. ```sh $ docker exec -it yb-tserver-n1 /home/yugabyte/bin/ysqlsh -h yb-tserver-n1 ``` ``` ysqlsh (11.2-YB-2.0.11.0-b0) Type "help" for help. ``` ```sh yugabyte=# CREATE TABLE foo(bar INT PRIMARY KEY); ``` ```sh $ docker exec -it yb-tserver-n1 /home/yugabyte/bin/ycqlsh yb-tserver-n1 ``` ``` Connected to local cluster at yb-tserver-n1:9042. [ycqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4] Use HELP for help. ycqlsh> ``` ```sh ycqlsh> CREATE KEYSPACE mykeyspace; ycqlsh> CREATE TABLE mykeyspace.foo(bar INT PRIMARY KEY); ycqlsh> DESCRIBE mykeyspace.foo; ``` Here is an example of a client that is defined within the same Docker Compose file. ```sh version: '2' volumes: yb-master-data-1: yb-tserver-data-1: networks: dbinternal: dbnet: services: yb-master: image: yugabytedb/yugabyte:latest container_name: yb-master-n1 networks: dbinternal volumes: yb-master-data-1:/mnt/master command: [ "/home/yugabyte/bin/yb-master", "--fsdatadirs=/mnt/master", "--master_addresses=yb-master-n1:7100", "--rpcbindaddresses=yb-master-n1:7100", "--replication_factor=1"] ports: "7000:7000" environment: SERVICE7000NAME: yb-master yb-tserver: image: yugabytedb/yugabyte:latest container_name: yb-tserver-n1 networks: dbinternal dbnet volumes: yb-tserver-data-1:/mnt/tserver command: [ "/home/yugabyte/bin/yb-tserver", "--fsdatadirs=/mnt/tserver", "--enable_ysql", "--rpcbindaddresses=yb-tserver-n1:9100", "--tservermasteraddrs=yb-master-n1:7100" ] ports: "9042:9042" "5433:5433" "9000:9000" environment: SERVICE5433NAME: ysql SERVICE9042NAME: ycql SERVICE6379NAME: yedis SERVICE9000NAME: yb-tserver depends_on: yb-master yb-client: image: yugabytedb/yb-sample-apps:latest container_name: yb-client-n1 networks: dbnet command: [ "--workload", "SqlInserts", "--nodes", "yb-tserver-n1:5433" ] depends_on: yb-tserver ``` For more examples, follow the instructions in the section with Docker. ```sh $ docker-compose -f ./docker-compose.yaml down ```