---
layout: docs
page_title: Deploy Consul client agent on Docker
description: >-
   Learn how to deploy a Consul client agent on a Docker container.
---

# Deploy Consul client agent on Docker

This topic provides an overview for deploying a Consul server when running Consul on Docker containers.

## Prerequisites

### Docker

You will need a local install of Docker running on your machine for this tutorial. You can find the instructions for installing Docker on your specific operating system [here](https://docs.docker.com/install/).

### Consul (Optional)

If you would like to interact with your containerized Consul agents using a local install of Consul, follow the instructions [here](/consul/docs/fundamentals/install) and install the binary somewhere on your PATH.

## Configure and run a Consul client

Next, deploy a containerized Consul client and instruct it to join the server by giving it the server's IP address. Do not use detached mode, so you can reference the client logs during later steps.

```shell-session
$ docker run \
   --name=fox \
   consul agent -node=client-1 -retry-join=172.17.0.2
```

```plaintext hideClipboard
==> Starting Consul agent...
              Version: '1.14.3'
           Build Date: '2022-12-13 17:13:55 +0000 UTC'
              Node ID: '2edc1554-13de-1476-fc20-1212aa29126d'
         Node name: 'client-1'
        Datacenter: 'dc1' (Segment: '')
            Server: false (Bootstrap: false)
          Client Addr: [127.0.0.1] (HTTP: 8500, HTTPS: -1, gRPC: -1, gRPC-TLS: -1, DNS: 8600)
         Cluster Addr: 172.17.0.3 (LAN: 8301, WAN: 8302)
    Gossip Encryption: false
     Auto-Encrypt-TLS: false
            HTTPS TLS: Verify Incoming: false, Verify Outgoing: false, Min Version: TLSv1_2
             gRPC TLS: Verify Incoming: false, Min Version: TLSv1_2
     Internal RPC TLS: Verify Incoming: false, Verify Outgoing: false (Verify Hostname: false), Min Version: TLSv1_2

==> Log data will now stream in as it occurs:

2022-12-15T18:59:45.065Z [INFO]  agent.client.serf.lan: serf: EventMemberJoin: client-1 172.17.0.3
2022-12-15T18:59:45.065Z [INFO]  agent.router: Initializing LAN area manager
2022-12-15T18:59:45.065Z [INFO]  agent: Started DNS server: address=127.0.0.1:8600 network=tcp
2022-12-15T18:59:45.066Z [INFO]  agent: Started DNS server: address=127.0.0.1:8600 network=udp
2022-12-15T18:59:45.066Z [INFO]  agent: Starting server: address=127.0.0.1:8500 network=tcp protocol=http
2022-12-15T18:59:45.066Z [INFO]  agent: started state syncer
2022-12-15T18:59:45.066Z [INFO]  agent: Consul agent running!
2022-12-15T18:59:45.066Z [INFO]  agent: Retry join is supported for the following discovery methods: cluster=LAN discovery_methods="aliyun aws azure digitalocean gce hcp k8s linode mdns os packet scaleway softlayer tencentcloud triton vsphere"
2022-12-15T18:59:45.066Z [INFO]  agent: Joining cluster...: cluster=LAN
2022-12-15T18:59:45.066Z [INFO]  agent: (LAN) joining: lan_addresses=["172.17.0.2"]
2022-12-15T18:59:45.066Z [WARN]  agent.router.manager: No servers available
2022-12-15T18:59:45.067Z [ERROR] agent.anti_entropy: failed to sync remote state: error="No known Consul servers"
2022-12-15T18:59:45.070Z [INFO]  agent.client.serf.lan: serf: EventMemberJoin: server-1 172.17.0.2
2022-12-15T18:59:45.071Z [INFO]  agent.client: adding server: server="server-1 (Addr: tcp/172.17.0.2:8300) (DC: dc1)"
2022-12-15T18:59:45.071Z [INFO]  agent: (LAN) joined: number_of_nodes=1
2022-12-15T18:59:45.071Z [INFO]  agent: Join cluster completed. Synced with initial agents: cluster=LAN num_agents=1
2022-12-15T18:59:46.454Z [INFO]  agent: Synced node info
```

In a new terminal, check that the client has joined by executing the `consul members` command again in the Consul server container.

```shell-session
$  docker exec badger consul members
```

```plaintext hideClipboard
Node      Address          Status  Type    Build   Protocol  DC   Partition  Segment
server-1  172.17.0.2:8301  alive   server  1.14.3  2         dc1  default    <all>
client-1  172.17.0.3:8301  alive   client  1.14.3  2         dc1  default    <default>
```

Now that you have a small datacenter, you can register a service and
perform maintenance operations.