# How to configure hashicorp nomad network part?

**URL:** <https://discuss.hashicorp.com/t/how-to-configure-hashicorp-nomad-network-part/24403>\
**Category:** Nomad\
**Created:** [May 15, 2021, 11:01pm UTC](https://discuss.hashicorp.com/t/how-to-configure-hashicorp-nomad-network-part/24403 "2021-05-15T23:01:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clivern](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/clivern/32/19396_2.png) [@Clivern](https://discuss.hashicorp.com/u/Clivern)\
**Post date:** [May 15, 2021, 11:01pm UTC](https://discuss.hashicorp.com/t/how-to-configure-hashicorp-nomad-network-part/24403/1 "2021-05-15T23:01:03Z")

</div>

Hi There!

I want to use nomad to replace docker-compose. In docker compose, you can specify the dependent containers and you will be able to reach the container with the name.

```
# DB Container
db:
    image: 'mysql:8.0'
    ....

# App Container
app:
    .....
    depends_on:
        - db

```

Things doesn’t seem that easy with nomad somehow! it feels i have to dig deep to understand the networking part or use `consul`. I have this basic test job that creates mysql container and another application container.

```
    job "hippo_services_db" {
      datacenters = ["dc1"]
    
      group "services" {
    
        volume "mysql_data" {
          type = "host"
          read_only = false
          source = "mysql_data"
        }
    
        network {
          port "mysql_srv" {
            static = 3306
          }
          port "toad_srv" {
            static = 8080
          }
        }
    
        task "mysql" {
          driver = "docker"
    
          volume_mount {
            volume = "mysql_data"
            destination = "/var/lib/mysql"
            read_only = false
          }
    
          config {
            image = "mysql:8.0"
    
            ports = ["mysql_srv"]
          }
    
          env {
              MYSQL_ROOT_PASSWORD = "root"
              MYSQL_DATABASE = "hippo"
              MYSQL_USER = "hippo"
              MYSQL_PASSWORD = "m06rs011e9h9ihuboi7s"
              MYSQL_ALLOW_EMPTY_PASSWORD = "no"
          }
    
          resources {
            cpu = 100
            memory = 900
          }
        }
    
        task "toad" {
          driver = "docker"
    
          config {
            image = "clivern/toad:release-0.2.4"
    
            ports = ["toad_srv"]
    
            command = "./toad"
    
            args = [
              "--port",
              "${NOMAD_PORT_toad_srv}",
            ]
          }
    
          env = {
            IS_STATEFUL = "false",
          }
    
          resources {
            network {
              mbits = 10
            }
          }
        }
      }
    }

```

from the application container `toad` i want to access the mysql container. You can install mysql client inside toad container as explained below. so far i can’t reach the database container from the app container.

```
$ docker ps
# Get the toad app container id
$ docker exec -it $ID bash
$ apt-get update && apt-get install -y git curl libmcrypt-dev default-mysql-client
$ mysql -h $IP -P 3306 -u root -proot

```

I am struggling with this for a day or so! any help would be much appreciated!

---

<div class="post-metadata">

**Author:** ![Clivern](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/clivern/32/19396_2.png) [@Clivern](https://discuss.hashicorp.com/u/Clivern)\
**Post date:** [May 16, 2021, 2:01am UTC](https://discuss.hashicorp.com/t/how-to-configure-hashicorp-nomad-network-part/24403/2 "2021-05-16T02:01:11Z")

</div>

I managed to get things working with consul. seems that’s the only way. But running containers lose internet connectivity!!

> **[Consul Connect | Nomad by HashiCorp](https://www.nomadproject.io/docs/integrations/consul-connect)**
>
> Learn how to use Nomad with Consul Connect to enable secure service to service communication

> **[Nomad Networking Demystified](https://www.hashicorp.com/resources/nomad-networking-demystified)**
>
> Learn about HashiCorp Nomad's networking capabilities, such as sidecar-less service mesh when integrated natively with Consul Connect, and see how the new container networking interface (CNI) support works.

---

<div class="post-metadata">

**Author:** ![Clivern](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/clivern/32/19396_2.png) [@Clivern](https://discuss.hashicorp.com/u/Clivern)\
**Post date:** [May 16, 2021, 2:37pm UTC](https://discuss.hashicorp.com/t/how-to-configure-hashicorp-nomad-network-part/24403/3 "2021-05-16T14:37:02Z")

</div>

Finally all my issues got solved! i was using old version 0.8.0 of CNI plugins 😃
