# Docker Container Password?

**URL:** <https://farmos.discourse.group/t/docker-container-password/1510>\
**Category:** Hosting farmOS\
**Created:** [February 7, 2023, 1:41am UTC](https://farmos.discourse.group/t/docker-container-password/1510 "2023-02-07T01:41:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtgis](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jtgis](https://farmos.discourse.group/u/jtgis)\
**Post date:** [February 7, 2023, 1:41am UTC](https://farmos.discourse.group/t/docker-container-password/1510/1 "2023-02-07T01:41:48Z")

</div>

![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/2X/f/ff5933a5f33a2afa52f2b57a238ee208fddb3d22.png)

I am a newbie to all of this. I have farmOS running on a vm (OCI) and when I try to set it up I am having DB connection issues. I decided that maybe I should build the mysql db in the docker container. But in order to do that it asks for a password? Anyone know what that password is?

Or if anyone has tips on connecting farmOS to the db that built on the vm outside of the docker container that would help too. I did some bind-address edits in my.cnf but that did not seem to help.

Thanks  
jt

---

<div class="post-metadata">

**Author:** ![jtgis](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jtgis](https://farmos.discourse.group/u/jtgis)\
**Post date:** [February 7, 2023, 1:46am UTC](https://farmos.discourse.group/t/docker-container-password/1510/2 "2023-02-07T01:46:45Z")

</div>

i found the user root and test in the forums but now i get this error:

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/2X/8/8d3daee9008a3090dc8dee2f34994cb42be0eded.png)

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [February 7, 2023, 1:07pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/3 "2023-02-07T13:07:42Z")

</div>

Hi @jtgis, welcome to the forum! 🙂

Can you describe some of the steps that you took to get to this point first? There are many ways to set up farmOS and its database in Docker.

If you are using the official MySQL Docker image it offers options for setting up the initial database user and password. See their docs here for more info: [Docker](https://hub.docker.com/_/mysql)

---

<div class="post-metadata">

**Author:** ![jtgis](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jtgis](https://farmos.discourse.group/u/jtgis)\
**Post date:** [February 7, 2023, 1:29pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/4 "2023-02-07T13:29:47Z")

</div>

Thanks for the welcome!

I am running it on an oracle cloud instance if that matters under ubuntu.

I followed up to this part of the install guide:

```auto
docker pull farmos/farmos:2.x.y
docker run --rm -p 80:80 -v "${PWD}/sites:/opt/drupal/web/sites" farmos/farmos:2.x.y

```

I also created a mysql db on my host machine, no docker.

My issue is when I am connecting to the db during setup:

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/2X/3/3345752bfc72fbaae51722c9eef1643ea9c5a620.png)

It has no access.

This is all user error on my part but i am stumped on how to give the farmos container access to the db i made. I tried some bind-address stuff to get the docker ip in there but did not really understand what i was doing and it did not work.

If there is anyone around who has a make a db and set it up so that the farmos docker can access it for dummies guide it would be helpful 🙂

---

<div class="post-metadata">

**Author:** ![jtgis](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jtgis](https://farmos.discourse.group/u/jtgis)\
**Post date:** [February 7, 2023, 1:38pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/5 "2023-02-07T13:38:48Z")

</div>

I might just follow the dev guide. This is for personal use so not much customization will happen. Although eventually I will try to add some x y z tiles to the map… ha

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [February 7, 2023, 2:53pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/6 "2023-02-07T14:53:59Z")

</div>

> [@jtgis](#):
>
> My issue is when I am connecting to the db during setup:

Have you tried expanding the “Advanced options” and putting in a host/ip for the database? I think it defaults to “localhost” which I don’t think would work in this scenario because localhost from within the docker container wouldn’t point to where your DB is hosted.

Check out [nginx - From inside of a Docker container, how do I connect to the localhost of the machine? - Stack Overflow](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach) - specifically the parts about `host.docker.internal` which is the preferred approach these days I believe.

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [February 7, 2023, 3:02pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/7 "2023-02-07T15:02:35Z")

</div>

Yea this is mainly a networking question. Think about the Docker container as one machine, and the host (where the database is installed) as a separate machine. They need to be able to talk to one another for the farmOS machine (the Docker container) to connect to the MySQL machine (the host container).

The way you have it set up is a little tricky, because from the perspective of the farmOS container, the host machine’s IP may change whenever you recreate the farmOS container. That is what `host.docker.internal` is meant to address… although as far as I know that only works with Docker for Mac/Windows, but you are on Ubuntu so it probably won’t work.

> I might just follow the dev guide.

That will definitely be easier to set up, because it makes all the decisions about database container and networking for you. Since both the farmOS container and the database container (PostgreSQL in the case of the dev environment) are managed together via Docker Compose, they are accessible to one another within their own little network, with hostnames of `www` and `db`, respectively, so they can talk to one another.

I would not recommend using the dev environment for real data, however. The upgrade process is bumpier, so going from one version of farmOS to another will require more manual work to do.

You could also consider running MySQL/PostgreSQL in Docker in the same way that the dev environment is set up. You just need to start with the `docker-compose.production.yml` (renamed to `docker-compose.yml`) and add in a container for the database to that file.

> <https://github.com/farmOS/farmOS/blob/2.x/docker/docker-compose.production.yml>

You could start by coping in the `db` config from the dev environment config:

```auto
  db:
    image: postgres:12
    volumes:
      - './db:/var/lib/postgresql/data'
    ports:
      - '5432:5432'
    environment:
      POSTGRES_USER: farm
      POSTGRES_PASSWORD: farm
      POSTGRES_DB: farm

```

And maybe make the password a bit more secure. 🙂

---

<div class="post-metadata">

**Author:** ![mstenta](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/mstenta/32/4_2.png) [@mstenta](https://farmos.discourse.group/u/mstenta)\
**Post date:** [February 7, 2023, 3:03pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/8 "2023-02-07T15:03:59Z")

</div>

> [@mstenta](#):
>
> although as far as I know that only works with Docker for Mac/Windows, but you are on Ubuntu so it probably won’t work.

Oh reading the link that @Symbioquine posted… maybe it is possible to use that on Linux now too! YMMV 🙂

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [February 7, 2023, 3:44pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/9 "2023-02-07T15:44:11Z")

</div>

> [@Symbioquine](#):
>
> Have you tried expanding the “Advanced options” and putting in a host/ip for the database? I think it defaults to “localhost” which I don’t think would work in this scenario because localhost from within the docker container wouldn’t point to where your DB is hosted.
> 
> Check out [mysql - From inside of a Docker container, how do I connect to the localhost of the machine? - Stack Overflow](https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach) - specifically the parts about `host.docker.internal` which is the preferred approach these days I believe.

I use 172.17.0.1 (default bridge address)  
I’m sure I tried host.docker.internal and it wouldn’t work on Pi OS.

---

<div class="post-metadata">

**Author:** ![Symbioquine](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/symbioquine/32/284_2.png) [@Symbioquine](https://farmos.discourse.group/u/Symbioquine)\
**Post date:** [February 7, 2023, 4:01pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/10 "2023-02-07T16:01:39Z")

</div>

> [@Farmer-Ed](#):
>
> I use 172.17.0.1 (default bridge address)  
> I’m sure I tried host.docker.internal and it wouldn’t work on Pi OS.

I think you may need use the “extra hosts” functionality to add the `host.docker.internal` alias. See the highlighted part;

 ![image](https://global.discourse-cdn.com/free1/uploads/farm_os/original/2X/d/d09d7389860327c6862ddaf1575bd3c5412c1712.png)

e.g. I think it would be something like this;

```sh
docker run --add-host=host.docker.internal:host-gateway --rm -p 80:80 \
    -v "${PWD}/sites:/opt/drupal/web/sites" farmos/farmos:2.x.y

```

or

```yaml
version: '3'
services:
  www:
    # Update this to the latest stable version before deploying.
    image: farmos/farmos:2.x.y
    volumes:
      - './sites:/opt/drupal/web/sites'
    ports:
      - '80:80'
    restart: always
    extra_hosts:
      - "host.docker.internal:host-gateway"

```

---

<div class="post-metadata">

**Author:** ![Farmer-Ed](https://yyz2.discourse-cdn.com/free1/user_avatar/farmos.discourse.group/farmer-ed/32/662_2.png) [@Farmer-Ed](https://farmos.discourse.group/u/Farmer-Ed)\
**Post date:** [February 7, 2023, 4:39pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/11 "2023-02-07T16:39:52Z")

</div>

> [@Symbioquine](#):
>
> `dd-host=host.docker.internal:host-gateway --rm -p 80:80 \`

Ah, that’s possibly a step I left out,  
but didn’t investigate it further since the bridge address worked.

---

<div class="post-metadata">

**Author:** ![jtgis](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@jtgis](https://farmos.discourse.group/u/jtgis)\
**Post date:** [February 7, 2023, 7:58pm UTC](https://farmos.discourse.group/t/docker-container-password/1510/12 "2023-02-07T19:58:10Z")

</div>

This seems to be the solution to my issue!

Thank you all for the pertinent information. I decided to go with the dev setup instructions and everything is working.

I might try this method later so that I have my own db external to docker that I can sync to somewhere else easier maybe?

Next projects regarding my setup will be to get a custom xyz tile service to work as a basemap and setting up the uploaded file directory following the instructions. My plan is to do all of these processes enough times that I have the process down and simple and will share my documentation.
