# Ignition Docker with sql database

**URL:** <https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [September 2, 2021, 6:46pm UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571 "2021-09-02T18:46:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [September 2, 2021, 6:46pm UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571/1 "2021-09-02T18:46:33Z")

</div>

Dear,

How do we need to do to connect a gateway running in docker with a sql database (Also in docker).

My connection stay always in faulted. When trying to connect with workbench the connection is working.

Regards

---

<div class="post-metadata">

**Author:** ![kyvislabs](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kyvislabs/32/26325_2.png) [@kyvislabs](https://forum.inductiveautomation.com/u/kyvislabs)\
**Post date:** [September 2, 2021, 7:51pm UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571/2 "2021-09-02T19:51:42Z")

</div>

Use the container name. If the containers are on the same docker network, the hostname is the container name.

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [September 7, 2021, 6:19pm UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571/3 "2021-09-07T18:19:56Z")

</div>

If you’re running independent containers, you could try having Ignition connect to the database by looping back to your host via `host.docker.internal`. That name will resolve to the IP of your host system, against which you can then connect to the published port you setup for the database (which you’re using to connect via workbench).

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 9, 2023, 10:17am UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571/4 "2023-03-09T10:17:11Z")

</div>

Thank you so much for this 😃  
I spent all morning trying to figure out how to connect to a dockerized database from a dockerized ignition !

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [March 9, 2023, 10:29am UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571/5 "2023-03-09T10:29:21Z")

</div>

Just check that new Elective course

> **[Ignition with Docker Course at Inductive University](https://inductiveuniversity.com/courses/elective-studies/ignition-with-docker)**
>
> Follow along in a guided walkthrough of Ignition with Docker. These topics will familiarize you with Docker concepts and we'll learn how to apply them with Ignition.

I found it very usefull when starting with docker

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [March 9, 2023, 10:35am UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571/6 "2023-03-09T10:35:10Z")

</div>

Thanks, I'll check this out when I can find the time.

---

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [March 9, 2023, 2:05pm UTC](https://forum.inductiveautomation.com/t/ignition-docker-with-sql-database/50571/7 "2023-03-09T14:05:03Z")

</div>

I'll also augment that as of Docker Engine 20.10, you can also use `host.docker.internal` mapping on Linux (where it was previously only available on Docker Desktop). You do have to add an `extra_hosts` mapping to your container definition though, such as:

```bash
docker run ... --add-host "host.docker.internal:host-gateway" ...

```

... or in your Compose YAML:

```yaml
services:
  gateway:
    ...
    extra_hosts:
      - "host.docker.internal:host-gateway"
    ....

```

With this, the hostname `host.docker.internal` will resolve to your `docker0` bridge IP on the host.
